package WebdriverDemo2;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Naukri {
public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
String exp = "Chandigarh";
driver.get("file:///C:/Users/NHCE/Desktop/Sample.html");
WebElement wele = driver.findElement(By.xpath("//optgroup[@label='------Punjab------']"));
List<WebElement> lst = wele.findElements(By.tagName("option"));
for(WebElement allopt : lst)
{
if(allopt.getText().equals(exp))
{
allopt.click();
}
}
}
}
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Naukri {
public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
String exp = "Chandigarh";
driver.get("file:///C:/Users/NHCE/Desktop/Sample.html");
WebElement wele = driver.findElement(By.xpath("//optgroup[@label='------Punjab------']"));
List<WebElement> lst = wele.findElements(By.tagName("option"));
for(WebElement allopt : lst)
{
if(allopt.getText().equals(exp))
{
allopt.click();
}
}
}
}
No comments:
Post a Comment