首页 文章

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

提问于
浏览
3

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

Chrome

var options = new OpenQA.Selenium.Chrome.ChromeOptions();
options.BinaryLocation = @"C:\Users\Vilem\AppData\Local\Google\Chrome\Application\";

using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options))
{
...

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

Could not find Chrome binary at:

C:\Users\Vilem\AppData\Local\Google\Chrome\Application

Firefox

new OpenQA.Selenium.Firefox.FirefoxDriver();

我也尝试了配置文件:

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

我得到的错误:

Unable to bind to locking port 7054 within 45000 ms

IE

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

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

我得到的错误:

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

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

谢谢

3 回答

  • 0

    我通过将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();
        }
    ...
    

    如果您还没有,可以从here下载.exe

  • 1

    Chrome

    无法在以下位置找到Chrome二进制文件:C:\ Users \ Vilem \ AppData \ Local \ Google \ Chrome \ Application

    我认为你必须指定包括可执行文件在内的整个路径 . 像 C:\Users\Vilem\AppData\Local\Google\Chrome\Application\chrome.exe (只是猜测,目前无法访问Windows机器)

    Firefox

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

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

  • 0

    您应该指定包含.exe的路径 . 那么,您的代码如下:

    options.BinaryLocation = @"C:\Users\Vilem\AppData\Local\Google\Chrome\Application\chrome.exe";
    new InternetExplorerDriver(@"C:\Program Files (x86)\IEDriver\iexplore.exe", ieOptions);
    

相关问题