package com.seleniumWebdriver;
import org.openqa.selenium.By;
import org.testng.annotations.Test;
/**
* @Blog Name : Selenium Code Example
* @author Deepak Gupta
* @Created Date 4-08-2017
*
*/
public class BasicCode extends SuperTestNG {
@Test
public void basicCodeTest() throws InterruptedException {
try {
driver.get("file:///D:/Office/Eclipse_Projects/Project_Neon/PracticeCode/SavedPage/Only%20Testing%20%20TextBox.htm");
driver.findElement(By.id("text2")).sendKeys("Test 1");
driver.findElement(By.id("text3")).sendKeys("Test 2");
driver.findElement(By.id("radio2")).click();
System.out.println("@@@@@@@@@@@@@@@@@@@@@@ basicCodeTest() method is stared @@@@@@@@@@@@@@@@@@@@@@");
// basic checkbox and radio checked verification
Boolean radio = driver.findElement(By.id("radio2")).isSelected();
if (radio == true) {
System.out.println("Radio Button Status: " + radio);
} else {
System.out.println("Radio Button Status: " + radio);
}
Boolean chkBox = driver.findElement(By.id("check1")).isSelected();
if (chkBox == true) {
System.out.println("Check Box Status: " + chkBox);
} else {
System.out.println("Check Box Status: " + chkBox);
}
// Get any attribute value from an element
String href = driver.findElement(By.linkText("Open New Page")).getAttribute("href");
System.out.println("Open New Page URL: " + href);
// get the text of any element
String textValue = driver.findElement(By.xpath("//div/h2/span")).getText();
System.out.println("Get text value is: " + textValue);
Thread.sleep(5000);
System.out.println("@@@@@@@@@@@@@@@@@@@@@@ basicCodeTest() method is ended @@@@@@@@@@@@@@@@@@@@@@");
} catch (Exception e) {
System.out.println("Expection is : " + e);
}
}
}
import org.openqa.selenium.By;
import org.testng.annotations.Test;
/**
* @Blog Name : Selenium Code Example
* @author Deepak Gupta
* @Created Date 4-08-2017
*
*/
public class BasicCode extends SuperTestNG {
@Test
public void basicCodeTest() throws InterruptedException {
try {
driver.get("file:///D:/Office/Eclipse_Projects/Project_Neon/PracticeCode/SavedPage/Only%20Testing%20%20TextBox.htm");
driver.findElement(By.id("text2")).sendKeys("Test 1");
driver.findElement(By.id("text3")).sendKeys("Test 2");
driver.findElement(By.id("radio2")).click();
System.out.println("@@@@@@@@@@@@@@@@@@@@@@ basicCodeTest() method is stared @@@@@@@@@@@@@@@@@@@@@@");
// basic checkbox and radio checked verification
Boolean radio = driver.findElement(By.id("radio2")).isSelected();
if (radio == true) {
System.out.println("Radio Button Status: " + radio);
} else {
System.out.println("Radio Button Status: " + radio);
}
Boolean chkBox = driver.findElement(By.id("check1")).isSelected();
if (chkBox == true) {
System.out.println("Check Box Status: " + chkBox);
} else {
System.out.println("Check Box Status: " + chkBox);
}
// Get any attribute value from an element
String href = driver.findElement(By.linkText("Open New Page")).getAttribute("href");
System.out.println("Open New Page URL: " + href);
// get the text of any element
String textValue = driver.findElement(By.xpath("//div/h2/span")).getText();
System.out.println("Get text value is: " + textValue);
Thread.sleep(5000);
System.out.println("@@@@@@@@@@@@@@@@@@@@@@ basicCodeTest() method is ended @@@@@@@@@@@@@@@@@@@@@@");
} catch (Exception e) {
System.out.println("Expection is : " + e);
}
}
}
No comments:
Post a Comment