2

I try to launch chrome using selenium on AWS windows 2019:

private final String chromeDriverPath = "src{0}main{0}resources{0}chromedriver{0}chromedriver.exe".replace("{0}", File.separator);
private final String chromePath = "C:{0}Program Files{0}Google{0}Chrome{0}Application".replace("{0}", File.separator);

@Test 
public void testSelenium() {
System.setProperty("webdriver.chrome.driver", this.chromeDriverPath);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary(this.chromePath);
chromeOptions.addArguments("--headless");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.close();
}

And I get this error:

Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}) on port 63701
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 3.41 s <<< FAILURE! - in TestSuite
org.openqa.selenium.WebDriverException: 
unknown error: Chrome failed to start: crashed.
  (chrome not reachable)
  (The process started from chrome location C:\Program Files\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '', ip: '', os.name: 'Windows Server 2019', os.arch: 'amd64', os.version: '10.0', java.version: '14.0.2'
Driver info: driver.version: ChromeDriver
remote stacktrace: Backtrace:
    Ordinal0 [0x0113C0C3+3326147]
    Ordinal0 [0x01020851+2164817]
    Ordinal0 [0x00EA7298+619160]
    Ordinal0 [0x00E1E4CB+58571]
    Ordinal0 [0x00E1C38A+50058]
    Ordinal0 [0x00E45F3E+220990]
    Ordinal0 [0x00E45CAC+220332]
    Ordinal0 [0x00E4189B+202907]
    Ordinal0 [0x00E23DF4+81396]
    Ordinal0 [0x00E24DEE+85486]
    Ordinal0 [0x00E24D79+85369]
    Ordinal0 [0x010385DC+2262492]
    GetHandleVerifier [0x012C2874+1487204]
    GetHandleVerifier [0x012C23CD+1486013]
    GetHandleVerifier [0x012CA368+1518680]
    GetHandleVerifier [0x012C2F4E+1488958]
    Ordinal0 [0x0102ED0D+2223373]
    Ordinal0 [0x0103A12B+2269483]
    Ordinal0 [0x0103A26F+2269807]
    Ordinal0 [0x0104ECB8+2354360]
    BaseThreadInitThunk [0x733A0419+25]
    RtlGetAppContainerNamedObjectPath [0x77B766ED+237]
    RtlGetAppContainerNamedObjectPath [0x77B766BD+189]

chromedriver version: 87.0.4280.88 chrome version: 87.0.4280.88 selenium version: 3.141.59

I verified chrome version:

Running command PowerShell -Command "(Get-Item (Get-ItemProperty 

'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe').'(Default)').VersionInfo"

ProductVersion   FileVersion      FileName                                     
--------------   -----------      --------                                     
87.0.4280.88     87.0.4280.88     C:\Program Files\Google\Chrome\Application...

I also tried adding the following arguments but nothing solved it:

chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--remote-debugging-port=9222");
chromeOptions.addArguments("--no-sandbox");

Edit: In chromedriver log I see this error:

[1608729679.424][DEBUG]: DevTools HTTP Request: http://localhost:49214/json/version
[1608729681.457][DEBUG]: DevTools HTTP Request failed
[1608729681.460][INFO]: [4e889dd42b249ac78f0ab49aab5abb6b] RESPONSE InitSession ERROR unknown error: Chrome failed to start: crashed.

Any ideas?

Roy
  • 123
  • 2
  • 9

1 Answers1

1

As per your current configuration this.chromePath is pointing towards:

C:\Program Files\Google\Chrome\Application\chrome.exe

where isn't installed.

You need to point towards the actual customized location of the Chrome binary through setBinary() attribute.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I don't understand what you mean. I did set binary to the chrome.exe path. I also printed the all the files in the folder and made sure chrome.exe file exists. So I don't understand what do you want me to change. thank you – Roy Dec 21 '20 at 10:26
  • Where does `this.chromeDriverPath` and `this.chromePath` point to? Check the versions initiating _ChromeDriver_ and _Chrome_ from _command line_ and check their versions if they match **chromedriver version: 87.0.4280.88** and **chrome version: 87.0.4280.88** and update the question accordingly. – undetected Selenium Dec 21 '20 at 10:57
  • updated the answer. I verified chrome version and chromedriver I downloaded from the website the version: 87.0.4280.88. Also added more trace and it says starting chromedriver 87.0.4280.88 – Roy Dec 21 '20 at 11:36
  • Do you have any idea what might be the problem? – Roy Dec 22 '20 at 09:43
  • So going by the discussion [which chromedriver version supports electron app?](https://stackoverflow.com/questions/65400461/which-chromedriver-version-supports-electron-app/65400583#65400583) possibly downgrading to _Chrome browser version is 80.0_ and _ChromeDriver v80.0.3987.106_ will solve your issue incase you are using electron app. – undetected Selenium Dec 22 '20 at 09:44
  • From a generic perspective the error stacktrace says there is a massive gap in the compatibility between the _Chrome_ and [ChromeDriver](https://stackoverflow.com/questions/59909654/how-does-chrome-driver-interact-with-chrome-browser/59927747#59927747). – undetected Selenium Dec 22 '20 at 09:50
  • This issue is not related to the electron issue. In this test I just try to launch regular chrome on windows 2019 server. All the solutions I found on internet says to add the arguments I already added. I will try to downgrade the versions but I prefer not to, especially such an older version. Any other ideas what could be the problem? EDIT: but I checked the chromedriver versions and browser versions and both of them are 87.0.4280.88 – Roy Dec 22 '20 at 09:50