Quality is delighting customers
Hi All,
I have a situation, where i have to select same value / different value from drop downs having same values in each. I am able to select value from first drop down but from second drop down i am not.
Please check the code i have written below.
public void clickDropdownByIdSelectValue(String inputid, String valuetotext){
driver.findElement(By.xpath("//input[@id='"+inputid+"']/parent::*//img")).click();
new WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//div[contains(@class,'x-combo-list-item')]/parent::*/div[text()='"+valuetotext+"']")));
driver.findElement(By.xpath("//div[contains(@class,'x-combo-list-item')]/parent::*/div[text()='"+valuetotext+"']")).click();
}
Html code is :
Tags:
So Selenium recognize the elements from left to right. So drop downs you have must consist of same values under it. So try out putting the brackets around the xpath and give the index of the drop down.
e.g.
driver.findElement(By.xpath( "(//x-path).[2]")).click(); (for the second drop down)
Try to get the values from second drop down. If it works we can try it out for the next drop down.
this should work.
You have use
List<WebELements> e = driver.findelementByclass("x-combo-list-item");
foreach(Weblement e1:e){
if (e.text ="Instrumental"){
e.click();}
}
Hi,
You can simply use the index value of the respective text to be selected in the xpath (if the order of dropdown remains same). E.g. */span[1], */span[2]
And then try to click the element.
This is a common method used by experts of automation testing company.
It should work.
Thanks,
Anand
© 2021 Created by Quality Testing.
Powered by