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();
}
}
While working with:
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");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With