Friday, 19 October 2018

DropDown menu testing by selenium webdriver

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;

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 exe 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

//Drop down menu testing in selenium

Select country = new Select(driver.findElement(By.xpath(".//*[@id='countries']")));
//three method is use for drop down testing
country.selectByIndex(0);
//index is start with zero and value is zero so it select Afghanistan
country.selectByValue("Afghanistan");
//value is given by developer
country.selectByVisibleText("Afghanistan");

driver.close();
}

}


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)...