<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>跟着安静学测试</title> </head> <body> <form action="demo-form.php"> 选择图片: <input type="file" name="img" multiple> <input type="submit"> </form> </body> </html> |
from selenium import webdriver import time driver = webdriver.Chrome() driver.get('E:\\web\\Upload.html') time.sleep(2) driver.find_element_by_name('img').send_keys('E:\\web\\123.jpg') |
from selenium import webdriver import time import pywinauto driver = webdriver.Chrome() driver.get('https://www.jq22.com/yanshi17984') driver.switch_to.frame("iframe") driver.find_element_by_class_name('addImg').click() time.sleep(2) # 通过窗口打开 app = pywinauto.Desktop() # 通过弹框名称进入控件中 win = app['打开'] # 输入上传图片的地址 win['Edit'].type_keys(r'E:\web\123.jpg') #点击打开按钮 win['Button'].click() |
import time from selenium import webdriver path = r'C:\Users\xxxxx\AppData\Local\Google\Chrome\User Data1' options = webdriver.ChromeOptions() # 增加个人浏览器地址 options.add_argument('--user-data-dir='+path) driver = webdriver.Chrome(chrome_options=options) driver.get('https://www.baidu.com') driver.find_element_by_id('kw').send_keys('chrome') driver.find_element_by_id('su').click() time.sleep(2) driver.find_element_by_xpath('//*[@class="c-btn c-btn-primary OP_LOG_BTN pc-js-btn_n7kWx"]').click() |
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |