Launching of GC when Selenium basic program is run

128 views Asked by At

I am running the following code in Eclipse but my Google Chrome is not launching.

The configurations are:

  • Eclipse IDE for Java Developers
  • Version: 2019-12 (4.14.0)
  • Have taken latest versions for GC driver.

The same code and config is working for another laptop but not on mine. Have re-installed the application several time. All the libraries available on internet have also been imported.

package automationFramework;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.*;

public class FirstTestCase {

    public static WebDriver driver;

    public static void main(String[] args) {
        System.setProperty("webdriver.firefox.driver", "C:\\Users\\WC-Parul\\Downloads\\geckodriver-v0.26.0-win64.zip");
        FirefoxDriver driver = new FirefoxDriver();
        driver.get("https://www.google.com/");
        // Launch the Online Store Website
        // driver.get("http://www.shop.demoqa.com");
        // Print a Log In message to the screen
        System.out.println("Successfully opened the website www.Store.Demoqa.com");
        // Close the driver
        // driver.quit();
    }
}
2

There are 2 answers

0
Ruyut On

you say Chrome? you are not use

FirefoxDriver driver = new FirefoxDriver();

you should

WebDriver driver = new ChromeDriver();

and you should download chromedriver.exe

Hope it helps you

If not, please take a screenshot "Java Build Path"

0
NarendraR On

Extract C:\\Users\\WC-Parul\\Downloads\\geckodriver-v0.26.0-win64.zip and provide geckodriver.exe path

Something like

System.setProperty("webdriver.firefox.driver", "C:\\Users\\WC-Parul\\Downloads\\geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");

Make sure your downloaded correct version of geckodriver

If you want to run the code on Chrome browser then download compatible chromedriver.exe from here as per your chrome browser version and use below code:

System.setProperty("webdriver.chrome.driver", "drive_path\chromedriver.exe");
ChromeDriver driver = new ChromeDriver();
driver.get("https://www.google.com/");