Monday, 7 August 2017

Code Example - Get Title Name

package com.seleniumWebdriver;

import org.testng.annotations.Test;

/**
 * @Blog Name : Selenium Code Example
 * @author Deepak Gupta
 * @Created Date 7-08-2017
 *
 */
public class GetTitleName  {

@BeforeTest
public void preCondtion() {
try {
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "/drivers/geckodriver.exe");
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

} catch (Exception e) {
org.testng.Assert.fail("Test failed");
}

}



@AfterClass
public void end(){
driver.quit();
}

@Test
public void getTitleExample() {
try {

driver.get("http://www.google.com");
System.out.println("Current Title Name: " + driver.getTitle());
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
}
}

No comments:

Post a Comment

Code Example - File Download By Robot Class In Firefox Browser

Exported from Notepad++ package com . practiceCode ; import java . awt . AWTException ; import java . awt . Robot ; import j...