javascript - Why Selenium can't find an element that is graphically visible -


i'm using selenium test appllication running on firefox browser, when want click on button selenium, don't find it. find strange since can see element eye. have tried multiple method worked other exemple :

  1. wait.until(expectedconditions.visibilityofelementlocated(by))
  2. wait.until(expectedconditions.presenceofelementlocated(by)); (i use xpath in path variable, , i'm sure correct)
  3. setting implictlywait on driver
  4. putting thread.sleep(1000)

then again, post here because don't understand why selenium not see element diplayed on browser. important information maybe giving me proper answer html dom dynamically generate websocket triggered javascript event.

edit 1:

<button type="button" class="btn btn-xs btn-block btn-stroke" id="252_button">     delete </button> 

the element i'm trying access. use xpath it.

it's not in iframe element.

to access element did method supposed find , click on giving xpath in parameter :

public void findandclick(string xpath) {         by = by.xpath(xpath);         //wait.until(expectedconditions.presenceofelementlocated(by));         wait.until(expectedconditions.visibilityofelementlocated(by));          driver.findelement(by).click();     } 

edit 2:

here specific xpath : //div[2]/div/div/div/button i've found using selenium plugins.

edit 3 :

the exception i'm getting

stalereferenceelementexception: element not found in cache - perhaps page has change since looked up.

i went page explain exception, says :

the element has been deleted entirely. element no longer attached dom. 

but can't be, becasue can see , click on manually.

i think found explanation of problem, read documention the stalereferenceexception. more precisely in part :

the element not attached dom

a common technique used simulating tabbed ui in web app prepare divs each tab, attach 1 @ time, storing rest in variables. in case, it's entirely possible code might have reference element no longer attached dom (that is, has ancestor "document.documentelement"). if webdriver throws stale element exception in case, though element still exists, reference lost. should discard current reference hold , replace it, possibly locating element again once attached dom.

i think i'm in same case because when use method (gettext(), gettag()) on reference of webelement have exception if element still graphically visible. understand it, try access reference no longer attached dom since dom have changed.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -