51Testing软件测试论坛

标题: 问下各位大佬这代码哪里出错了,用python自动上传多个图片 [打印本页]

作者: zhangwuxuan    时间: 2019-8-2 20:31
标题: 问下各位大佬这代码哪里出错了,用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[3]/div[2]/form/div/div/div/div[2]/button[1]').click()
        file_path = "D:\\%s.png"%i
        os.system("F:\\upload.exe%s" %file_path)
# if driver.find_element_by_xpath('/html/body/div[3]/div[2]/form/div/div/div/div[2]/button[1]').click():
#      print('图片上传成功!')
# else:
#     print('图片上传失败')
# driver.quit()


作者: zhangwuxuan    时间: 2019-8-2 20:33
#脚本文件代码
WinWait("CLASS:#32770","",5)
ControlFocus("文件上传", "", "Edit1")
WinWait("[CLASS:#32770]", "", 10)
ControlSetText("文件上传" ,"", "Edit1",$CmdLine[1])
Sleep(2000)
ControlClick("文件上传", "","Button1");

作者: sxgsw3    时间: 2019-8-8 19:56
os.system("F:\\upload.exe%s" %file_path)
os.system("F:\\upload.exe %s" %file_path)    jio本和文件路径中间加个空格




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2