![](/img/trans.png)
[英]Selenium Python right click “Open link in new Window” - (Windows 7)
[英]Windows Files does not open when click in webpage “Select file”. Selenium Python
所以,我需要将文件上传到页面。 当我点击输入按钮(它点击没有错误)时,windows 文件搜索我需要的文件,没有打开。 这是我的代码片段。 以及我需要在点击时打开的内容
#IMPORTAR DATOS
selec = driver.find_element_by_xpath('//*[@name="IMPORT_FILE"]')
driver.execute_script("arguments[0].click();", selec)
time.sleep(2)
[![Windows 文件][1]][1]
通过pip
安装pyautogui
并执行此操作。
import pyautogui
... # set the webdriver etc.
...
...
element_present = EC.presence_of_element_located((By.XPATH, "//button[@title='Open file selector']")) # Example xpath
WebDriverWait(self.driver, 10).until(element_present).click() # This opens the windows file selector
pyautogui.write('C:/path_to_file')
pyautogui.press('enter')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.