zhangwuxuan 发表于 2019-8-2 20:31:43

问下各位大佬这代码哪里出错了,用python自动上传多个图片

from selenium import webdriver
import os
import time
# 打开浏览器
driver=webdriver.Firefox()
driver.get('http://127.0.0.1:8080/BabyPlan/login.jsp')

#登录
driver.find_element_by_id('userName').send_keys('user')
driver.find_element_by_id('password').send_keys('user11')
driver.find_element_by_id('loginbtn').click()

#进入爸妈天地
driver.find_element_by_link_text('爸妈天地').click()
driver.find_element_by_link_text("照片列表").click()


#上传照片
driver.find_element_by_id('photobtn').click()
time.sleep(2)
driver.find_element_by_id("txtPhotoImg").click()
#调用zz.exe可执行程序
# os.system('F:\\upload.exe')
#上传图片

#
for i in range(3):
        driver.find_element_by_xpath('/html/body/div/div/form/div/div/div/div/button').click()
        file_path = "D:\\%s.png"%i
        os.system("F:\\upload.exe%s" %file_path)
# if driver.find_element_by_xpath('/html/body/div/div/form/div/div/div/div/button').click():
#      print('图片上传成功!')
# else:
#   print('图片上传失败')
# driver.quit()

zhangwuxuan 发表于 2019-8-2 20:33:24

#脚本文件代码
WinWait("CLASS:#32770","",5)
ControlFocus("文件上传", "", "Edit1")
WinWait("", "", 10)
ControlSetText("文件上传" ,"", "Edit1",$CmdLine)
Sleep(2000)
ControlClick("文件上传", "","Button1");

sxgsw3 发表于 2019-8-8 19:56:58

os.system("F:\\upload.exe%s" %file_path)
os.system("F:\\upload.exe %s" %file_path)    jio本和文件路径中间加个空格
页: [1]
查看完整版本: 问下各位大佬这代码哪里出错了,用python自动上传多个图片