Dcode78
Dcode78

Reputation: 13

Running Selenium-java automation within gitpod.io

New to SO & test automation & selenium. I got introduced to gitpod while attempting https://www.lambdatest.com/certifications/.

I'm stuck trying to run the below simple code snippet in side Gitpod.

package project.maven.selenium;
import org.openqa.selenium.WebDriver;
import io.github.bonigarcia.wdm.WebDriverManager;

public class WebDriverManagerDemo {

    public static void main(String[] args) throws InterruptedException {
        
        WebDriver driver = WebDriverManager.chromedriver().create();
        
        // Navigate to the demoqa website
        driver.get("https://www.lambdatest.com/selenium-playground/checkbox-demo");
        Thread.sleep(3000);
        
        driver.quit();

    }
        
}

Couldn't find a way pass the error below,

Exception in thread "main" io.github.bonigarcia.wdm.config.WebDriverManagerException: There was an error creating WebDriver object for Chrome at io.github.bonigarcia.wdm.WebDriverManager.instantiateDriver(WebDriverManager.java:1775) at io.github.bonigarcia.wdm.WebDriverManager.create(WebDriverManager.java:425) at project.maven.selenium.WebDriverManagerDemo.main(WebDriverManagerDemo.java:9) Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

Can someone please point out what I'm doing wrong here?

Researched hours but Selenium on Gitpod is not much of a topic, read the getting started guide with Gitpod too, to find a resolution to my problem but no luck before posting here.

Upvotes: 0

Views: 309

Answers (1)

Shawn
Shawn

Reputation: 8478

Below line of code is incorrect:

WebDriver driver = WebDriverManager.chromedriver().create();

Try the below code:

 public static void main(String[] args) throws InterruptedException {
        
        // below line is used to setup chromedriver using WDM
        WebDriverManager.chromedriver().setup();

        //initialize the driver object
        WebDriver driver = new ChromeDriver();
        
        // Navigate to the demoqa website
        driver.get("https://www.lambdatest.com/selenium-playground/checkbox-demo");
        Thread.sleep(3000);
        
        driver.quit();

    }

Upvotes: 0

Related Questions