Csharp/C#教程:Selenium WebDriver – 没有司机在为我工作分享


Selenium WebDriver – 没有司机在为我工作

我正在努力让Selenium测试运行。 我正在使用C#。 我遇到的每个司机都遇到了问题。

var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.BinaryLocation = @"C:UsersVilemAppDataLocalGoogleChromeApplication"; using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options)) { ... 

好像找到了chromedriver.exe,但它可以找到Chrome二进制文件。 在自动搜索失败后,我明确设置了chrome.exe的路径。 我甚至在最后尝试使用“chrome.exe”。 我总是得到相同的结果:

找不到Chrome二进制文件:

C:用户 Vilem 应用程序数据本地谷歌镀铬应用

火狐

 new OpenQA.Selenium.Firefox.FirefoxDriver(); 

我也尝试了配置文件:

 FirefoxProfile profile = new FirefoxProfile(@"E:...FirefoxProfile"); new OpenQA.Selenium.Firefox.FirefoxDriver(); 

我得到的错误:

无法在45000毫秒内绑定到锁定端口7054

IE

 var ieOptions = new InternetExplorerOptions(); ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; new InternetExplorerDriver(@"C:Program Files (x86)IEDriver", ieOptions); 

带有驱动程序的文件夹也在PATH中设置。

我得到的错误:

 No response from server for url https://localhost:6955/session 

有什么我想念的吗? 如果他们中的任何一个工作,我会很高兴。

谢谢

我通过将chromeDriver和IE_driver的.exe放在项目/ bin /文件夹中来使Chrome和IE工作

防爆。

 VisualStudio2010/Projects/ProjName/ProjName/bin/chromedriver.exe 

然后在设置测试时我做了:

 using OpenQA.Selenium.Chrome; ... private IWebDriver chrome; ... [SetUp] public void SetupTest() { chrome= new ChromeDriver(); baseURL = "url-goes-here"; verificationErrors = new StringBuilder(); } ... 

如果你还没有,可以从这里下载.exe

找不到Chrome二进制文件:
C:用户 Vilem 应用程序数据本地谷歌镀铬应用

我认为你必须指定包括可执行文件在内的整个路径。 像C:UsersVilemAppDataLocalGoogleChromeApplicationchrome.exe (只是猜测,目前无权访问Windows机器)

火狐

无法在45000毫秒内绑定到锁定端口7054

你不应该永久得到它。 最快的解决方案,告诉你没有回答很多问题:重启(或登出登录)。 如果您在重新启动后仍然可以获得该function,请查看有关它的问题并发布您自己的问题。

您应该指定包含.exe的路径。 所以,你的代码如下:

上述就是C#学习教程:Selenium WebDriver – 没有司机在为我工作分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

 options.BinaryLocation = @"C:UsersVilemAppDataLocalGoogleChromeApplicationchrome.exe"; new InternetExplorerDriver(@"C:Program Files (x86)IEDriveriexplore.exe", ieOptions); 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1011570.html

(0)
上一篇 2021年12月30日
下一篇 2021年12月30日

精彩推荐