Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
616 views
in Technique[技术] by (71.8m points)

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

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:userssemashkoappdatalocalempmpr7lojx/.'

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...