[英]How to load a existing FirefoxProfile through Selenium and Python
First time posting here, so I address a problem I cannot solve.Checked Stackoverflow and google. 第一次在这里发布,所以我解决了一个我无法解决的问题。检查了Stackoverflow和google。 There's some answers for java which I couldn't decode.
有一些我无法解码的答案。 Therefore you might mention that this is a duplicate, but so far no one answered such a question.
因此,您可能会提到这是重复的,但是到目前为止,没有人回答过这样的问题。
Any ideas will be really appreciated. 任何想法将不胜感激。
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")
geckodriver: 0.23.0 壁虎:0.23.0
python: 3.7.1 的Python:3.7.1
selenium: 3.141.0 硒:3.141.0
Windows: 10 1511 Windows:10 1511
Try with: 尝试:
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")
To load an existing Firefox Profile through Selenium and Python you can use the following solution: 要通过Selenium和Python加载现有的 Firefox配置文件 ,可以使用以下解决方案:
Code Block: 代码块:
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()
Console Output: 控制台输出:
Page Title is : Google
References: 参考文献:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.