In last post, we have learnt how to launch Chrome driver through selenium. In this post we will learn:
Selenium 3 has been launched. In selenium 2, it was very easy to launch Firefox browser as Selenium 2 had native implementation of Firefox browser. As we know that Selenium provides a driver class for each browser. So to open Firefox browser, we just need to create an object of FirefoxDriver class as below:
FirefoxDriver driver= new FirefoxDriver();
Note: “driver” is an object or reference variable of class FirefoxDriver. You can name it anything you wish. Someone asked me that is “driver” fixed. So, I am putting this point here.
Selenium 3 has not any native implementation of Firefox browser. Marionette is the next generation of FirefoxDriver. Marionette is an automation driver for Mozilla’s Gecko engine. Gecko is the proprietary web browser engine design and developed by Mozilla. It can remotely control either the UI or the internal JavaScript of a Gecko platform, such as Firefox. So, to support Selenium webdriver, Gecko has released Geckodriver which is a proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers.
How to launch Firefox browser in SELENIUM 3:
Step 1: Download the latest geckodriver from here as per your system configuration. I will download for windows 64 bits.
Step 2: Extract it and so that you will get geckodriver.exe.
Step 3: Just set the system property using System class and setProperty method of it as we did for chrome browser in previous post.
Java code for opening Firefox browser is as below:
import org.openqa.selenium.firefox.FirefoxDriver;
public class LaunchFirefoxBrowser {
public static void main(String[] args) {
//setting path of geckodriver
System.setProperty("webdriver.gecko.driver", "D:/Organised/Selenium_Frameworks/DataDrivenFramework/exefiles/geckodriver.exe");
// Launching firefox browser
FirefoxDriver FDriver= new FirefoxDriver();
// Opening a URL
FDriver.get("https://www.google.com");
// Closing the browser
FDriver.quit();
}
}
Note:
There are some issues with geckodriver. Sometimes we will face:
That’s it for this post. I hope, you must have get above concepts. Feel free to ask any doubt if you have or any suggestion for me.
#HappyLearning
Hello Guys, As I say always, your automation script is ineffective if you do not include logic to validate to…
"How much Java I need to learn for selenium with Java binding?" is mostly asked question by a Professional who…
Hello Guys, You should not be able to type alphabets or special characters in a field which supposed to accept…
Hello Folks, Recently a guy asked me this question which he was asked in an interview in IBM. What the…
Hello Folks, As part of our API Testing series, we will see “Sending GET request with params in Postman”. In last…
We have learnt in previous posts regarding establishing relationship between test methods. You can go through them below: Dependency in…