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.



Launch Firefox browser using Geckodriver - Selenium 3.0
Launch Firefox browser using Geckodriver - Selenium 3.0

Must Read

Generate HTML Reports using Selenium
Selenium WebDriver Methods
TestNG examples to execute Multiple Classes
Read Data From properties file using Selenium


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;
 
 @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.

Output:


Testng Test output

TestNG Test output

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

Post a comment

0 Comments