'Locating an element within another element
public LocatedCarParksMap locateAndClickOnTheCardByAddressIndicator(String location) {
List<WebElement> quoteCards = driver.findElements(By.cssSelector(".quote-card"));
for (WebElement webElement : quoteCards) {
WebElement locationElement = webElement.findElement(By.cssSelector(".quote-card-asset-location"));
if (locationElement.getText().equals(location)) {
webElement.findElement(By.xpath(".rate-card-description")).click();
}
throw new NoSuchElementException();
}
return this;
}
- Locating list of cards
- iterating through it and locating needed card by locating the element that contains the address i am looking for
- if address is the one i am looking for i am trying to find .rate-card-description within the same card element and then clicking on it to proceed further
I have debugged it and it does locates the address from the card however it cant locate an element within the yellow text are for me to click on
What i am doing wrong, thank you
Solution 1:[1]
Use Explicit Wait:
WebDriverWait wait =newWebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath('Locator'))
Or use:
elementToBeClickable()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Software Tester at ExpandCart |
