相关疑难解决方法(0)

如何使用Python + Selenium WebDriver保存和加载cookie

如何将Python的Selenium WebDriver中的所有cookie保存到txt文件中,然后再加载它们?该文档没有说明getCookies函数的任何内容.

python selenium webdriver

78
推荐指数
6
解决办法
9万
查看次数

如何使用Python Selenium Webdriver在chrome中加载默认配置文件?

因此,我想使用pythons webdriver打开其默认配置文件的chrome.我已经尝试了我能找到的所有东西,但我仍然无法让它发挥作用.谢谢您的帮助!

python selenium-chromedriver

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

如何将现有配置文件与 Selenium Webdriver 一起使用?

我正在尝试使用 Python 的Selenium Webdriver以及Firefox位于<PROFILE-DIR>.

我尝试过的

#!/usr/bin/env python

from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver import Firefox, DesiredCapabilities
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options

options = Options()
options.profile = '<PROFILE_DIR>'
webdriver = Firefox(options=options)
Run Code Online (Sandbox Code Playgroud)

这会将现有配置文件复制到临时位置。我可以看到它有效,因为我启动的新会话可以访问配置文件的旧cookie等。但这不是我想要的:我想就地使用配置文件。

  • 尝试将配置文件作为“--profile”传递给args功能:将上面的代码更改为
capabilities = DesiredCapabilities.FIREFOX.copy()
capabilities['args'] = '--profile <PROFILE-DIR>'
webdriver = Firefox(desired_capabilities=capabilities)
Run Code Online (Sandbox Code Playgroud)

什么也没做:关闭会话后查看geckodriver.log仍然显示类似的内容Running command: "/usr/bin/firefox" "--marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileOFKY46",即仍在使用临时配置文件(它甚至不是 …

python firefox selenium-webdriver

7
推荐指数
1
解决办法
1522
查看次数