Friday, 4 August 2017

Code Example - CalendarPopup

package com.seleniumWebdriver;

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

/**
 * @Blog Name : Selenium Code Example
 * @author Deepak Gupta
 * @Created Date 4-08-2017
 *
 */
public class CalendarPopup extends SuperTestNG {

public void handleFrame() {
WebElement ele = driver.findElement(By.className("demo-frame"));
driver.switchTo().frame(ele);

}

@Test
public void handleCalendarPopup() {
try {
driver.get("https://jqueryui.com/datepicker/");
handleFrame();
driver.findElement(By.id("datepicker")).click();
driver.findElement(By.xpath("//a[text()='20']")).click();

String value = driver.findElement(By.id("datepicker")).getAttribute("value");
System.out.println("Selected Date is : " + value);
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...