Launch Firefox browser using Geckodriver – Selenium 3.0

Launch Firefox browser using Geckodriver – Selenium 3.0,Selenium is an open source automation tool which will automate different web applications in different browsers.Selenium releasing different versions with some new requirements and new changes,Recently Selenium releases Selenium 3.0 beta version for below language bindings.In this post ,I am going to explain how to work with Firefox browser with Gecko driver using Selenium 3.0 beta version.In order to work with Selenium 3.0 beta version ,you require java 8+ version should be install in your personal machine or laptop.

Must Read

Run Selenium scripts using Command Line
Run Selenium Scripts using Runnable JAR
TOP Selenium Interview Questions asked in MNC
How to Send attachments in Jenkins emails
Selenium XPATh tutorial step by step
How to run TestNG test cases using Maven

ALSO READ  How to Select a Dropdown in Selenium WebDriver using Java

Selenium Language Bindings

Selenium 3.0 beta version for Java
Selenium 3.0 beta version for C#
Selenium 3.0 beta version for Ruby

In Selenium 3.0 beta version they have added some changes i.e Firefox browser will work only using Mozilla’s Gecko driver which is downloads from GitHub.

download geckodriver from github

 

Let’s write the script to run test scripts in Firefox Browser using Gecko drives
How to Di it?
1)Download Gecko driver from GitHub and add it to System.setProperty().
System.setProperty(“webdriver.gecko.driver”, “E:/Selenium_tutorials/geckodriver.exe”);
2)Same driver like driver=new FireffoxDriver();

Script

package com.keyword.driverscript;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class ScrollBar {

public static WebDriver driver;
public static String baseUrl;

ALSO READ  Selenium WebDriver Automation Test Life Cycle

@BeforeTest
public void setup(){

System.setProperty(“webdriver.gecko.driver”, “F:\Java_Applications\Zip Files\geckodriver.exe”);
driver = new FirefoxDriver();
driver.manage().window().maximize();
baseUrl=“http://www.softwaretestutorials.blogspot.in”;

}

@Test
public void pageScroll(){
driver.navigate().to(baseUrl);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.linkText(“Selenium Tutorials”)).click();
}
}

Once you run the script Right click on Script and Run as – TestNG Test then it will open Firefox browser and execute the script using gecko driver ,Like this we can open Firefox browser using Gecko drives like for Chrome,IE browsers.

ALSO READ  Selenium WebDriver Scripting Guidelines

Output:

Testng Test output

TestNG Test output

Please provide your valuable comments and suggestions on this post.Thank you for reading my blog.

 

Rajesh K

Leave a Reply

Your email address will not be published. Required fields are marked *