1

It's my first post here. I know everyone's been getting this error eversince the Google Chrome update. I'm a beginner in programming and here are my dependenceis

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.rcv</groupId>
    <artifactId>SeleniumTraining</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.8.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>3.8.1</version>
        </dependency>
    </dependencies>
</project>

And here are the initial code lines:


    String report = "Report of Anna's DemoAutomation:";

    static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd HH:mm");
    String now = formatter.format(ZonedDateTime.now());
    static ChromeOptions options;
    static WebDriver driver;

    static String variablesHere = "variablesHere";

    public void setUp() {
        
        options = new ChromeOptions().setExperimentalOption("debuggerAddress", "localhost:9014");
        options.addArguments("--disable-notifications");
        options.addArguments("--remote-allow-origins=*");
        driver = new ChromeDriver(options);

        report(report);
        report("Time started: " + now + "\n");

        System.setProperty("webdriver.chrome.driver",
                "C:\\Users\\Anna\\Downloads\\chromedriver_win32 (1)\\chromedriver.exe");

        driver.manage().window().maximize();
        driver.get("https://google.com");

So I've tried to use the other solutions I found on the internet such as adding options.addArguments("--remote-allow-origins=*") and also did try to add the dependency

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-http-jdk-client</artifactId>
  <version>4.5.0</version>
</dependency>

and set the system property to

 System.setProperty("webdriver.http.factory", "jdk-http-client");

But both solutions didn't work and I am still getting the errors. What a nightmare. Please help.

0

2 Answers 2

0

I see you have WebDriverManager dependency, but not using it in code, you can try something like:

WebDriverManager.chromedriver().capabilities(<chrome-options-here>).create(),

Also, if you do place chromedriver.exe manually, you should set system property webdriver.chrome.driver before instantiating ChromeDriver()

In both of these cases the error should differ from the above though

Sign up to request clarification or add additional context in comments.

Comments

0

This worked for me after I have installed new version : Version: 118.0.5993.70 (r1192594) chrome driver from link : https://googlechromelabs.github.io/chrome-for-testing/

System.setProperty("webdriver.chrome.driver", "path...\\chromedriver.exe");

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");
        
        driver = new ChromeDriver(options);

1 Comment

This argument allows web pages to make cross-origin requests to a WebDriver server. By specifying *, it effectively allows requests from any origin. This is useful in scenarios where your web application needs to interact with a WebDriver server from different origins or domains. Without this option, the same-origin policy enforced by web browsers might block such requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.