相关疑难解决方法(0)

使用Chrome驱动程序通过python和selenium在指定位置下载文件

我试图通过selenium的点击功能自动下载一些链接,我使用chrome webdriver和python作为编程语言.如何通过python程序选择下载目录,以便它不会下载到默认的Downloads目录中.我找到了firefox的解决方案,但每次点击链接时都会弹出下载对话框,这在Chrome中不会发生.

python selenium google-chrome driver download

17
推荐指数
4
解决办法
3万
查看次数

如何使用 Selenium ChromeDriver 和 Chrome 在自定义位置下载文件

我想将 txt 和 pdf 文件下载到特定文件夹。但它只是将它们下载到另一个文件夹中。网站http://demo.automationtesting.in/FileDownload.html。代码有问题还是我没有放置正确的文件夹位置?

import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chromeOptions=Options()
chromeOptions.add_experimental_option("prefs", {"download.default_dictionary": "C:\DownloadedAutomationFiles"})

driver=webdriver.Chrome(executable_path="D:\ChromeDriverExtracted\chromedriver", chrome_options=chromeOptions)
driver.get("http://demo.automationtesting.in/FileDownload.html")
driver.maximize_window()

driver.find_element_by_id("textbox").send_keys("testing")
driver.find_element_by_id("createTxt").click()   #generate file button
driver.find_element_by_id("link-to-download").click()    #dowload link


#Download PDF FILE

driver.find_element_by_id("pdfbox").send_keys("testing download text file")
driver.find_element_by_id("createPdf").click()   #generate file button
driver.find_element_by_id("pdf-link-to-download").click()    #dowload link

time.sleep(2)
driver.close()
Run Code Online (Sandbox Code Playgroud)

python selenium google-chrome selenium-chromedriver webdriverwait

5
推荐指数
1
解决办法
1万
查看次数