C#从Azure云服务运行ChromeDriver Selenium

时间:2015-09-22 15:16:59

标签: c# azure selenium selenium-chromedriver

我们使用Azure Cloud服务来托管MVC应用程序,该应用程序为客户端数据中的管理功能提供UI。希望从应用程序托管Selenium自动化。

当我在项目中捆绑ChromeDriver时,以下代码在Azure模拟器中本地运行:

public SeleniumService(string username, string password, string path)
    {
        Username = username;
        Password = password;
        var driverPath = Path.Combine(new string[] { path, "driver" });
        driver = new ChromeDriver(driverPath);
        driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(Timeout));
    }

但是当我从Azure运行时,Selenium也需要Chrome二进制文件。我将二进制文件打包在项目目录中,如果我在ChromeOptions中指定二进制路径...

public SeleniumService(string username, string password, string path)
    {
        Username = username;
        Password = password;
        var driverPath = Path.Combine(new string[] { path, "driver" });

        ChromeOptions options = new ChromeOptions()
        {
            BinaryLocation = Path.Combine(new string[] { path, "binary" })
        };
        driver = new ChromeDriver(driverPath,options);
        driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(Timeout));
    }

...我收到错误:

  

未知错误:chrome无法启动(驱动程序信息:chromedriver = 2.19.346078(6f1f0cde889532d48ce8242342d0b84f94b114a1),platform = Windows NT 6.3 x86_64)

我使用的是ChromeDriver 2.19,捆绑的Chrome.exe版本为45.0.2454.93

谢谢!

0 个答案:

没有答案
相关问题