如何在没有EULA的情况下启动ChromeDriver.exe? [英] How to Start ChromeDriver.exe without EULA?

查看:124
本文介绍了如何在没有EULA的情况下启动ChromeDriver.exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习使用Selenium(v2.20)来领先我们的一些程序员,他们很快就会用它创建一些浏览器测试。我想在他们到达之前发现陷阱,并且我偶然发现了一个。



当我创建我的ChromeDriver时,它始终会显示Google Chrome EULA并提供两个按钮:接受和运行和取消。我希望这是一个自动化测试,让用户点击一个按钮是不可能的。



我查看了 Chromium Command Switches ,但是没有找到任何可行的工具,也没有提到EULA。如果我(在断点处)单击接受并运行,然后让代码继续,则测试可以正常工作。



代码,直到导致问题的行,如下所示:

 使用(var driverService = ChromeDriverService.CreateDefaultService(@C:\Apps\ChromeDriver\ ))
{
driverService.Start();

//这行代码弹出EULA
IWebDriver驱动程序=新的C​​hromeDriver(@C:\Apps\ChromeDriver\);

//其余的测试...
}

有其他人遇到这个问题吗?如果是这样,你是如何解决它的?



UPDATE 4/4/12

我刚刚运行相同的代码在我的电脑上工作,我成功了,但没有触发EULA(符合Slanec的经验)。这让我相信,原因是环境问题。我正在研究两个系统(两个Win7 x64)之间的差异以确定原因。一旦我有更多的信息,我会更新。



非常感谢,



$如果您仍然遇到此问题,则会发生此错误,因为您每次运行测试时都会打开一个全新的Chrome浏览器实例,从而触发EULA。如果您将默认chrome配置文件复制到您选择的自定义位置,然后将--user-data-dir = yourcustomlocation标志添加到ChromeOptions中,则可以绕过EULA并打开现有配置文件。

  ChromeOptions crOptions = new ChromeOptions(); 
crOptions.AddArgument(@ - user-data-dir = C:\custom location);
返回新的ChromDriver(crOptions);


I am learning to use Selenium (v2.20) to get ahead of some of our programmers who will soon be creating some browser tests with it. I'd like to uncover the pitfalls before they get there, and I've stumbled into one.

When I create my ChromeDriver, it always brings up a "Google Chrome EULA" and presents two buttons: "Accept and Run" and "Cancel". As I want this to be an automated test, having a user click a button is out of the question.

I looked at a list of Chromium Command Switches but did not find any that worked, nor any that mentioned EULA. The test works fine if I (at a breakpoint) click "Accept and Run" and then let the code continue.

The code, up to the line that causes the problem, is below:

using (var driverService = ChromeDriverService.CreateDefaultService(@"C:\Apps\ChromeDriver\"))
{
    driverService.Start();

    // This line pops up the EULA
    IWebDriver driver = new ChromeDriver(@"C:\Apps\ChromeDriver\");

    // rest of test...
}

Has anyone else run into this issue? If so, how did you solve it?

UPDATE 4/4/12
I just ran the same code on my computer at work and I succeed without triggering the EULA (consistent with Slanec's experience). This leads me to believe the cause is environmental. I'm looking into the differences between the two systems (both Win7 x64) to determine the cause. I'll update once I have more information.

Thanks much,

-Seth

解决方案

In case you still have this problem, the error occurs because you are opening up a brand new instance of the chrome browser every time you run the test, thereby triggering the EULA. If you copy the default chrome profile into a custom location of your choice, and then add the "--user-data-dir=yourcustomlocation" flag to ChromeOptions, you can bypass the EULA and open up the existing profile instead.

ChromeOptions crOptions = new ChromeOptions();
crOptions.AddArgument(@"--user-data-dir=C:\custom location"); 
return new ChromDriver(crOptions);

这篇关于如何在没有EULA的情况下启动ChromeDriver.exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆