Tuesday, 8 August 2017

Code Example - Navigate Browser

package com.seleniumWebdriver;

import org.openqa.selenium.By;
import org.testng.annotations.Test;

/**
 * @Blog Name : Selenium Code Example
 * @author Deepak Gupta
 * @Created Date 8-08-2017
 *
 */

public class NavigateBrowser extends SuperTestNG {

@Test
public void handleNavigateBrowser() {
try {
driver.get("https://jqueryui.com/datepicker/");
System.out.println("Current URL is: " + driver.getCurrentUrl());

driver.findElement(By.linkText("Autocomplete")).click();
Thread.sleep(2000);
System.out.println("After Clicked Link Current URL is: " + driver.getCurrentUrl());
// browser back
driver.navigate().back();
System.out.println("After Navigate Back Current URL is: " + driver.getCurrentUrl());
Thread.sleep(2000);
// browser forward
driver.navigate().forward();
System.out.println("After Navigate Forword Current URL is: " + driver.getCurrentUrl());
Thread.sleep(2000);
// refresh page
driver.navigate().refresh();
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...