Selenium - Python webdriver path error system can't find the path specified

佐手、 提交于 2020-01-28 11:15:41

问题


Please help, whats wrong with the FF profile. I want to save a file from the website using Firefox and python webdriver

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select
import os
"""from bs4 import BeautifulSoup"""

fp = webdriver.FirefoxProfile()

fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.download.dir", os.getcwd())
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/html")

driver = webdriver.Firefox(firefox_profile=fp)
driver.get("http://achecker.ca/checker/index.php")
assert "Web Accessibility Checker" in driver.title
options = driver.find_element_by_link_text("Options")
options.click()
check_WCAG10 = driver.find_element_by_id("radio_gid_4")
check_WCAG10.click()
elem = driver.find_element_by_id("checkuri")
input_url = "naturasiberica.ru"
elem.send_keys(input_url)
elem.send_keys(Keys.RETURN)
# wait for result
try:
    element_exp_form = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "fileselect")))
except:
    driver.quit()
export_format = Select(driver.find_element_by_id("fileselect"))
export_format.select_by_value("html")
get_file = driver.find_element_by_id("validate_file_button")
get_file.click()
# wait for file_download
try:
    element_exp_form = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "fileselect"))
    )
finally:
    driver.quit()
driver.quit()

Then I have an error: [Error 3] The system cannot find the path specified: 'c:\users\semashko\appdata\local\temp\tmpr7lojx/.'

来源:https://stackoverflow.com/questions/27058053/selenium-python-webdriver-path-error-system-cant-find-the-path-specified

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!