相关疑难解决方法(0)

使用Java使用Selenium WebDriver加载Chrome配置文件

我遇到了一些让Selenium加载镀铬配置文件的麻烦.

String pathToChrome = "driver/chromedriver.exe";
System.setProperty("webdriver.chrome.driver", pathToChrome);

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
String chromeProfile = "C:\\Users\\Tiuz\\AppData\\Local\\Google\\Chrome\\User Data\\Default";
ArrayList<String> switches = new ArrayList<String>();
switches.add("--user-data-dir=" + chromeProfile);
capabilities.setCapability("chrome.switches", switches);
WebDriver driver = new ChromeDriver(capabilities);
driver.get("http://www.google.com");
Run Code Online (Sandbox Code Playgroud)

它开始很好并且工作得很完美,但是我想要加载默认配置文件,因为我想测试它,启用了一些Extensions并测试了一些首选项.

有没有人知道为什么这段代码不起作用?

我在Windows 7 x64上用Selenium 2.29.1和2.28.0以及chromedriver 26.0.1383.0测试了它.

java profile google-chrome selenium-webdriver

15
推荐指数
5
解决办法
7万
查看次数

使用Python通过Selenium WebDriver打开chrome扩展

我创建了一个chrome扩展,它对数据库进行API调用,并获取与当前打开的网站相关的一些数据.例如,如果我打开target.com并点击扩展名,它将为您提供与target.com相关的数据.

我试图通过selenium web驱动程序为它编写自动化测试,我可以定期运行它进行回归测试.要测试扩展,我需要先打开扩展(通常我们通过单击扩展图标来完成).

我尝试过不同的方法尝试点击扩展图标但没有成功.(例如,使用键盘快捷键ALT - LEFT_ARROW - SPACE但不能通过webdriver工作).

我也试过这个(这里提到):

options = webdriver.ChromeOptions()
options.add_argument("--app-id = mbopgmdnpcbohhpnfglgohlbhfongabi")
Run Code Online (Sandbox Code Playgroud)

但上面的代码没有帮助打开扩展.

我很感激有关如何在Selenium Webdriver中使用python执行此操作的任何想法.

python selenium google-chrome google-chrome-extension selenium-webdriver

9
推荐指数
2
解决办法
1万
查看次数

我如何在普通浏览器中使用selenium

是否可以将selenium连接到我正常使用的浏览器而不是驱动程序?对于正常浏览,我使用带有几个插件的chrome - 添加块加,flashblock等等.我想尝试使用此特定配置加载网站.我怎样才能做到这一点?

ps - 我不想只连接到这个问题中的开放浏览器:

如何连接已经打开的浏览器?

如果我使用驱动程序生成进程,我不在乎.我只想要完整的浏览器配置 - cookies,插件,字体等.

谢谢

python selenium python-2.7

6
推荐指数
1
解决办法
2827
查看次数

selenium webdriver 导入选项给我一个 ImportError

链接到我试图在我的代码中实现的原始代码。

使用带有扩展名(.crx 文件)的 Python 运行 Selenium WebDriver

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chop = webdriver.ChromeOptions()
chop.add_extension('Adblock-Plus_v1.4.1.crx')
driver = webdriver.Chrome(chrome_options = chop)
Run Code Online (Sandbox Code Playgroud)

我尝试合并代码,但第二行,

from selenium.webdriver.chrome.options import Options
Run Code Online (Sandbox Code Playgroud)

正在抛出一个错误

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    from selenium.webdriver.chrome.options import Options
ImportError: No module named options
Run Code Online (Sandbox Code Playgroud)

我更新了 selenium,更新了 chromedriver,这个问题并没有消失。我检查了stackoverflow,似乎与我找到模块的问题无关。

python selenium google-chrome-extension selenium-chromedriver selenium-webdriver

4
推荐指数
1
解决办法
6938
查看次数