C # Launching ChromeDriver series from Azure Cloud Service

we use the Azure Cloud service to host the MVC application, which provides a user interface for admin functions through our customer data. Looking to launch Selenium Automation from an app.

When I bundle ChromeDriver in a project, the following code works locally in an Azure emulator:

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));
    }

However, when I run from Azure, Selenium also needs the Chrome binary. I packed the binary in the project directory and if I specify the binary path in 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));
    }

... I get an error message:

unknown error: chrome failed to start (driver information: chromedriver = 2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1), platform = Windows NT 6.3 x86_64)

ChromeDriver 2.19, Chrome.exe - 45.0.2454.93

!

+4

Source: https://habr.com/ru/post/1608522/


All Articles