[英]How to load a existing FirefoxProfile through Selenium and Python
第一次在這里發布,所以我解決了一個我無法解決的問題。檢查了Stackoverflow和google。 有一些我無法解碼的答案。 因此,您可能會提到這是重復的,但是到目前為止,沒有人回答過這樣的問題。
任何想法將不勝感激。
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary(r'C:\Program Files (x86)\MozillaFirefox\firefox.exe')
profile = FirefoxProfile(r'C:\Users\User\Documents\dxcwavid.Zydrius5')
driver = webdriver.Firefox(firefox_profile = profile, firefox_binary = binary)
driver.get("http://google.com")
壁虎:0.23.0
的Python:3.7.1
硒:3.141.0
Windows:10 1511
嘗試:
binary = FirefoxBinary("C:\Program Files (x86)\MozillaFirefox\firefox.exe")
profile = FirefoxProfile("C:\Users\User\Documents\dxcwavid.Zydrius5")
driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary)
driver.get("http://google.com")
要通過Selenium和Python加載現有的 Firefox配置文件 ,可以使用以下解決方案:
代碼塊:
from selenium import webdriver myprofile = webdriver.FirefoxProfile(r'C:\\Users\\AtechM_03\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\moskcpdq.SeleniumTest') driver = webdriver.Firefox(firefox_profile=myprofile, executable_path=r'C:\\Utility\\BrowserDrivers\\geckodriver.exe') driver.get('https://www.google.co.in') print("Page Title is : %s" %driver.title) driver.quit()
控制台輸出:
Page Title is : Google
參考文獻:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.