简体   繁体   中英

Selenium webdriver unable to find this one particular element

I tried looking around for a solution, but haven't found any. Webdriver is unable to find this one particular element for some reason.

Here's the html code:

<div id=​"cboxOverlay" style="opacity: 1; cursor: auto; display: none;">​</div>​

And I am using xpath to find this element

By.xpath("//div[@id = 'cboxOverlay' and contains(@style, 'display: none;')]")

When I use firefinder, I can find this element. But it times out and doesnt find the element when I run the code

WebElement cboxOverlayWebElement = driver.findElement(cboxOverlay);

I have also tried using explicit wait to wait till the element is clickable or visible. Also I am using Java.

Could someone help me? Thanks!!

@Sweta

In your html code there is "display: none" means cboxoverlay would not be display. So webdriver also did not get it. Try to fine out what action makes this overlay display and then according write your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM