我在哪裏可以找到描述我可以在Selenium和Chrome瀏覽器中使用的選項的文檔?我想在Web瀏覽器中打開一個鏈接(以獲取憑據),但不要下載相應的文件(.pdf或.tiff或.jpeg)。我在Windows 7筆記本電腦上使用Python 2.7,selenium 3.0.1和Chrome Version 54.0.2840.99(和chromedriver.exe)。如何使用Chrome中的Selenium Python綁定來控制文件的下載
# Chrome web browser
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
#options.add_argument('--disable-download-notification') #doesn't seems to work
#options.add_experimental_option("prefs", {"download.default_directory","C:\Users\xxx\downloads\Test"}) # doesn't work
#options.add_experimental_option("prefs", {"download.prompt_for_download": False}) # doesn't seems to work
#options.add_experimental_option("prefs", {'profile.default_content_settings': {'images': 2}})# this will disable image loading in the browser
options.add_argument("user-agent="+user_agent_profile)
driver_main = webdriver.Chrome(chrome_options=options)
# opening the web application portail
driver_main.get("https://my_link")
我發現了很多關於這個主題的討論,但沒有一個解決方案的工作原理。例如:
add_experimental_option("prefs", {"download.default_directory","C:\Users\xxx\downloads\Test"})
不爲我
相同的工作:
add_experimental_option("prefs", {"download.prompt_for_download": False})
(我也有 「假」 試試)
同時:
add_argument("user-agent="+user_agent_profile)
似乎工作!
我不知道要明白什麼是錯的
我的問題是,它開始給每個我打開一個文件名(1)文件中的鏈接時,下載文件(2)....文件(99)然後從100開始打開一個彈出窗口「另存爲」。所以我想要麼根本不下載文件,要麼可以將其移動到「回收站」中的特定文件夾中。
如何找到哪些選項可以與add_argument和add_argument一起使用?我想看看鉻://約/但我看不出有直接對應
非常感謝
乾杯
法比安斯基
更改下載路徑,這一點 - ' 「download.default_directory」, 「C:\\ \\用戶\\ XXX \\下載測試」 '。它對我來說很有魅力。 –