![](/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.