5

iam running a selenium script and keep on getting the above error. here is the code:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class WhatsappTest {

    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "C:\\Users\\PC-Name\\Documents\\selenium jars\\chromedriver_win32\\chromedriver.exe");

        ChromeOptions options = new ChromeOptions();
        options.addArguments("user-data-dir=C:\\Users\\PC-Name\\AppData\\Local\\Google\\Chrome\\User Data");
//      options.addArguments("--no-sandbox");
//        options.addArguments("--disable-dev-shm-usage");

        WebDriver driver = new ChromeDriver(options);

        //Puts an Implicit wait, Will wait for 10 seconds before throwing exception
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        //Maximize the browser
        driver.manage().window().maximize();
        //Launch website
        driver.navigate().to("https://www.facebook.com/");
        System.out.println(driver.getTitle());

        driver.close();
    }

}

So the commented line in the code have not worked for me. I am getting this error always when I am adding this line:

options.addArguments("user-data-dir=C:\\Users\\Manish\\AppData\\Local\\Google\\Chrome\\User Data");

and code working fine without adding the above line.

here is more about the error:

(unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)

System Info: Windows 7 SP-1 64-bit

Chrome Info: Version 71.0.3578.98 (Official Build) (64-bit)

Java Version: 10.0.1

Please help me with this.

Manish singh
  • 108
  • 1
  • 3
  • 13
  • 1
    @DebanjanB none of the solution from that thread is working for me. Have already checked and then posted this question. So can you please remove the duplicate mark or if possible, please help me with this error. – Manish singh Dec 14 '18 at 04:42
  • Can you update the question to demonstrate how this question is different from the dup marked question? Here most of us are developers and want to keep [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) – undetected Selenium Dec 14 '18 at 07:12

1 Answers1

0

Your path is invalid...most likely because of the space. Try this instead:

options.addArguments("user-data- 
dir=C:\\Users\\Manish\\AppData\\Local\\Google\\Chrome\\User_Data");

If that doesn't work there are other markers that have been used to replace a space.

Zach Pedigo
  • 396
  • 2
  • 9
  • Here is a good example: https://askubuntu.com/questions/530578/how-to-write-the-path-of-a-folder-with-space-in-its-name – Zach Pedigo Dec 13 '18 at 18:43
  • i think this is not the problem the code is accepting the file location and opening a chrome instance with my existing setting but after that code is getting crashed – Manish singh Dec 14 '18 at 04:51
  • try to give \\ at the end, code is working fine in my system. Thanks. – Naeemahemad Dec 14 '18 at 18:38