0

I have an issue when trying a simple test with selenium avec chromedriver. I get the error org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist

This has been reported a couple of time on stackoveflow, i've read near all the answers without success at this time. I'm using a corporate managed computer without admin rights, using chrome 86.0.4240 with same version of chromedriver, selenium-standalone-server 3.9.1.

The code used is below, with the trace of different tries according to different stackoverflow topics found.

 public static void main(String[] args) {
  System.setProperty("webdriver.chrome.driver","C:\\Users\\" + System.getProperty("user.name") + "\\Downloads\\chromedriver_win32\\chromedriver.exe");
  
  ChromeOptions options = new ChromeOptions();
  Proxy proxy = new Proxy();
  proxy.setHttpProxy("127.0.0.1:9000");
  options.setCapability("proxy", proxy);
  
  // Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
  // https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t/51326137#51326137
  options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
  options.addArguments("start-maximized"); // open Browser in maximized mode
  options.addArguments("disable-infobars"); // disabling infobars
  options.addArguments("--disable-extensions"); // disabling extensions
  options.addArguments("--disable-gpu"); // applicable to windows os only
  options.addArguments("--no-sandbox"); // Bypass OS security model
      
  // All chrome process are previously killed : Get-Process -Name chrome* | Stop-Process
  // https://stackoverflow.com/questions/59987080/invalidargumentexception-message-invalid-argument-user-data-directory-is-alre 
  //options.addArguments("--user-data-dir=C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Local\\Google\\Chrome\\Automation\\");
      
  WebDriver driver = new ChromeDriver();
  driver.get("https://www.google.com"); }

When i run the test, Chrome Open, display the message tell it's controlled by an automated tool, display "data:" in the URL bar and hang. After a couple of seconds (minutes), the script ends with the above error.

I'm runing on a plain windows 10 plateform, with no docker. I cannot create a new chrome profile, so i take care to close all chrome process before starting the test.

Any help will be greatly appreciated.

vba
  • 1
  • 2
  • this error is thrown when chromedriver can't find a certain file it needs to communicate with Chrome. (So Chrome probably failed to create a directory or a file in your app_data folder) To confirm, try to create a new user profile in Chrome. On your computer, open Chrome. At the top right, click Profile Profile. Click Add. Choose a name and a photo. Does that work? – pcalkins Oct 29 '20 at 23:37
  • @pcalkins this work, i'm able to do thoses steps this way. How can i progress from here? one more question : is it supposed to create a new directory somewhere in my user profile? i don't see anything more in C:\Users\{username}\AppData\Local\Google\Chrome – vba Oct 30 '20 at 02:29
  • Not real sure... but Chrome will create some temporary files/folder when launching in dev-tools/debug mode... it's probably not the same location. Something's failing during that process. It's hard to say why that's failing, but the error is thrown when it can't find the file it needs to get information about setting up communication between the webdriver and the browser. I believe that'll be app_data\local\temp... I think the most likely scenario is the browser is crashing. (Does it stay open?) Why that is I don't know. Usually it's due to using the wrong chromedriver version. – pcalkins Oct 30 '20 at 16:50
  • I would eliminate all options and the proxy... see if it launches then. Add them back one by one to see if one is causing an issue. – pcalkins Oct 30 '20 at 16:52
  • btw, I just realized your code already is run without options. Is this by design? You are creating a ChromeOptions object but never using it. – pcalkins Oct 30 '20 at 17:49
  • 1
    Ah !!! how stupid am i to not see this before. Thank you for pointing me my error @pcalkins. btw, the only option really needed in my case is the --headless. I don't know how to mark the question answered thanks to you. – vba Nov 04 '20 at 02:01
  • Does this answer your question? [WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser](https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t) – OrangeDog Nov 16 '20 at 11:59
  • The question was answered by pcalkins, i just don't know how to mark the question as answered – vba Nov 17 '20 at 14:55

0 Answers0