Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch Firefox using Selenium

I am Trying to lunch Firefox and do a simple search on Google but i am only able to launch the Firefox. what should be edit in the code to run it smooth?I am Using Firefox Quantum 57 which runs using maven dependencies.

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirefoxLaunch
{
    @Test
    public static void main(String [] args) {
        WebDriver driver;
        driver = new FirefoxDriver();
        driver.get("https://google.com");
        WebElement element =driver.findElement(By.name("q"));
        element.sendKeys("FirefoxDriver Search Function");
        driver.quit();
    }
}
like image 229
Lakmal Rajith Avatar asked Sep 12 '26 01:09

Lakmal Rajith


1 Answers

While working with:

  • Selenium v3.x java clients
  • Firefox Quantum v70.x

You need to download the geckodriver binary from this link and save it in your system and then provide the absolute path of GeckoDriver binary through System.setProperty() line as follows :

System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe");
like image 118
undetected Selenium Avatar answered Sep 14 '26 14:09

undetected Selenium