admin管理员组文章数量:1310126
I want to get to a particular session in firefox, so my login data is saved
from selenium import webdriver
profile_path = "/home/XXXX/.mozilla/firefox/XXXX.selenium1" # particular profile - I hid some part of the path for privacy reason
options = webdriver.FirefoxOptions()
options.add_argument(f"--profile={profile_path}")
driver = webdriver.Firefox(options=options)
driver.get(url)
However, the get seems not to work. Firefox opens but I need to navigate to the page manually.
Instead, if I do not use a profile, i.e.,
from selenium import webdriver
driver = webdriver.Firefox()
driver.get(url)
Firefox opens the right page... but of course, I am not logged in.
I would like to get the first script to work.
I want to get to a particular session in firefox, so my login data is saved
from selenium import webdriver
profile_path = "/home/XXXX/.mozilla/firefox/XXXX.selenium1" # particular profile - I hid some part of the path for privacy reason
options = webdriver.FirefoxOptions()
options.add_argument(f"--profile={profile_path}")
driver = webdriver.Firefox(options=options)
driver.get(url)
However, the get seems not to work. Firefox opens but I need to navigate to the page manually.
Instead, if I do not use a profile, i.e.,
from selenium import webdriver
driver = webdriver.Firefox()
driver.get(url)
Firefox opens the right page... but of course, I am not logged in.
I would like to get the first script to work.
Share Improve this question edited Feb 3 at 14:13 TylerH 21.1k77 gold badges79 silver badges112 bronze badges asked Feb 2 at 11:02 SamSam 3241 gold badge4 silver badges22 bronze badges1 Answer
Reset to default 1You can try to export the session's cookies to use them in the future sessions: Start your selenium session, login to your FireFox profile, then:
with open(path, "wb") as file:
pickle.dump(driver.get_cookies(), file)
In the next sessions load the cookies as follows:
with open(path, "rb") as file:
cookies = pickle.load(file)
for cookie in cookies:
driver.add_cookie(cookie)
本文标签: pythonNavigate Firefox with SeleniumStack Overflow
版权声明:本文标题:python - Navigate Firefox with Selenium - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741850779a2401057.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论