Thursday 18 October 2018

Automation testing of form element

Form Element testing using selenium WebDriver


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class FormElement {

public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.driver.chromedriver","D:\\vishal\\selenium\\chromedriver_win32\\dasdf\\chromedriver.exe");
//path of exes file of chromedriver
WebDriver driver = new ChromeDriver();
//create object of webdriver as a driver name
driver.get("http://demo.automationtesting.in/Register.html");
//url of testing site

                //testing of text box

WebElement firstname=driver.findElement(By.xpath(".//*[@id='basicBootstrapForm']/div[1]/div[1]/input"));
//WebElement firstname=driver.findElement(By.name(""));
//WebElement firstname=driver.findElement(By.id(""));
//we also use id and name
firstname.sendKeys("vishal");


                //Testing of radio button
WebElement male = driver.findElement(By.xpath(".//[@id='basicBootstrapForm']/div[5]/div/label[1]/input"));
male.click();
//Testing of check box is also same like radio buttom
WebElement hobbies_cricket = driver.findElement(By.xpath(".//*[@id='checkbox1']"));
hobbies_cricket.click();
//testing of buttom
WebElement submit_button = driver.findElement(By.xpath(""));
submit_button.click();
driver.close();
//this command is close your browser after complete automation is complete
}

}

No comments:

Post a Comment

Jmeter

Database Testing: (1) Add mysql JDBC to Jmeter lib folder and restart Jmeter (2) Right click on test name -> add  Thread group (3)...