Selenium 3.0

Selenium 3.0 with firefox

package com.tutorial.one;

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

public class Firefox {
 private WebDriver driver;
 private String baseUrl;

@BeforeClass
 public void setUp() throws Exception {
 System.out.println("setting GeckoDriver");
 System.setProperty("webdriver.gecko.driver", "C:\\Users\\tarun\\geckodriver.exe");
 driver = new FirefoxDriver();
 baseUrl = "http://tfortesting.com";
 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
 }

@Test
 public void openSite() throws Exception{
 System.out.println("opening tfortesting.com");
 driver.get(baseUrl);
 driver.manage().window().maximize();
 driver.findElement(By.linkText("Java")).click();
 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
 }

@AfterClass
 public void endTest() throws Exception{
 driver.quit();
 }
 }

Selenium 3.0 with Chrome

package com.tutorial.one;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.*;

public class Chrome {
 private WebDriver driver;
 private String baseUrl;
 
 @BeforeClass
 public void setUp() throws Exception {
 System.out.println("setting Chrome driver");
 System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
 driver = new ChromeDriver();
 baseUrl = "http://tfortesting.com";
 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
 }
 
 @Test
 public void openSite() throws Exception{
 System.out.println("opening tfortesting.com in chrome browser");
 driver.get(baseUrl);
 driver.manage().window().maximize();
 driver.findElement(By.linkText("Java")).click();
 Thread.sleep(5000);
 }
 
 @AfterClass
 public void endTest() throws Exception{
 driver.quit();
 }
}

Leave a Reply

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

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑