- I can manually inspect and get the xpath of the element.
- when I get the xpath of that element, it says 1 of 1. I can create a unique Xpath for the element.
- But the selenium cannot find it.
I’m using Waits. So, there is no problem of skipping an element. But, There is also not any iframe in html. still The selenium cannot able to find the element which I’ve create the Xpath for. I provided a screen shot of that issue.
This is the code for that:
webEssentials.waitTillElementIsAvailableInDOM(By.xpath("//select[@name='senderId']"));
webEssentials.waitTillElementIsClickable(selectSenderId);
WebElement element = webEssentials.driver.findElement(By.xpath("//select[@name='senderId']"));
Select select = new Select(element);
select.selectByIndex(0);
webEssentials.waitTillElementIsVisible(templateZoho).
waitTillElementIsClickable(templateZoho);
WebElement element1 = webEssentials.driver.findElement(By.xpath("//select[@name='template']"));
Select select1 = new Select(element1);
select1.selectByIndex(0);
[1]: https://drive.google.com/drive/folders/1rvqESd2SE4cUqGyY7FK-8brI_q_F-6am?usp=sharing This Link having the error log of what I’m getting after the selenium cannot find the element
2
Answers
The desired element is an Angular element. To select one of the select-options from a html-select tag you need to induce WebDriverWait for the
elementToBeClickable()
and you can use either of the following Locator Strategies:Using name:
Using cssSelector:
Using xpath:
References
You can find a couple of relevant detailed discussions in:
Assuming that your xpath is correct. Then can you please use javaScriptExecutOr method to lcik the lement. Below is the sample code: Also pleas refer link
Can you please check also-> whether there is any frame available, then you need to switch to that frame first.