javamavenselenium-webdriverazure-devopsazure-devops-hosted-agent

Getting diff. error for chrome driver on azure hosted agent


Error :

org.openqa.selenium.WebDriverException: 
unknown error: Chrome failed to start: was killed
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location D:/a/1/s/src/test/resources/drivers/chromedriver.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'fv-az45', ip: '10.1.0.4', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_222'
Driver info: driver.version: ChromeDriver
remote stacktrace: Backtrace:
    Ordinal0 [0x013D7C53+1473619]
    Ordinal0 [0x0135AD71+961905]
    Ordinal0 [0x012E42B3+475827]
    Ordinal0 [0x0127C2AB+49835]
    Ordinal0 [0x01299149+168265]
    Ordinal0 [0x01298D1D+167197]
    Ordinal0 [0x0129742B+160811]
    Ordinal0 [0x01280AE6+68326]
    Ordinal0 [0x01281BF0+72688]
    Ordinal0 [0x01281B89+72585]
    Ordinal0 [0x01374B37+1067831]
    GetHandleVerifier [0x01476845+506677]
    GetHandleVerifier [0x014765E0+506064]
    GetHandleVerifier [0x0147D188+533624]
    GetHandleVerifier [0x0147701A+508682]
    Ordinal0 [0x0136C226+1032742]
    Ordinal0 [0x0136C09F+1032351]
    Ordinal0 [0x01376A4B+1075787]
    Ordinal0 [0x01376BB3+1076147]
    Ordinal0 [0x01375B65+1071973]
    BaseThreadInitThunk [0x773562C4+36]
    RtlSubscribeWnfStateChangeNotification [0x775F1F69+1081]
    RtlSubscribeWnfStateChangeNotification [0x775F1F34+1028]

I tried to run my selenium test on Azure hosted agent with diff. agents i.e Win1803, win2019, ubunt-16.04 etc.

I updated chromedriver and chromedriver.exe in code based on Os I select in the above agent.

For ubuntu, I am getting an error like: driver is not executable.

I have created the maven project and using Selenium and Java with it. It runs fine in my local but on Azure pipeline with a hosted agent.

Code I am using :

 HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
        ChromeOptions options = new ChromeOptions();
        options.setExperimentalOption("prefs", chromePrefs);
        DesiredCapabilities cap = DesiredCapabilities.chrome();
        cap.setJavascriptEnabled(true);
        cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        cap.setCapability(ChromeOptions.CAPABILITY, options);
        System.setProperty("webdriver.chrome.driver", Constants.AppPath.CHROME_PATH);
        chromePrefs.put("profile.default_content_settings.popups", 0);
        chromePrefs.put("download.default_directory", downloadFilepath);
       // options.addArguments("--headless");
        //options.addArguments("--window-size=1366,768");
        options.setBinary(Constants.AppPath.CHROME_PATH);
        options.addArguments("--no-sandbox");
        options.addArguments("--disable-popup-blocking");
        options.addArguments("--disable-dev-shm-usage");
        options.addArguments("--disable-gpu");
        options.addArguments("--dns-prefetch-disable");
        options.addArguments("--always-authorize-plugins");
        options.addArguments("enable-automation");
        options.addArguments("--disable-browser-side-navigation");
        options.addArguments("--ignore-certificate-errors");
        options.addArguments("--disable-extensions");
        options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
        driver = new ChromeDriver(options);

Solution

  • Here is a similar case with the same error ,maybe you can find a solution from it, please refer to it for more details.

    An accepted workaround is :

    1.Try to download HERE and use this latest chrome driver version. https://sites.google.com/a/chromium.org/chromedriver/downloads

    2.If you have already downloaded the latest chromedriver, try adding the 3 arguments:

    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-dev-shm-usage')
    d = webdriver.Chrome('/home/PycharmProjects/chromedriver',chrome_options=chrome_options)
    d.get('https://www.google.nl/')