0
votes

HTML Tags

<li class="filter-categ">
  <ul class="l-h-list">
     <li id="filter__entityBased" class="item filter_value" filter-name="entityBased" search-        name="zone/concept/store_based">Zone/Concept/Store based</li>
     <li id="entityBased" class="sprite-filter all-filter"></li>
  </ul>
</li>

I am trying to click on the element with id=entityBased, but I am getting the error."Error: element is not attached to the page document" Same works fine in Firefox and IE. Problem is seen only in Chrome.

I am using the following code to perform the action.

browser.element(:id => "entityBased").wait_until_present
browser.element(:id => "entityBased").click

My Environment Details

Chrome Version 29.0.1547.66 m Watir-WebDriver (0.6.4, 0.6.2) watir (4.0.2 ruby x86-mingw32)

This is blockin my automation in Chrome. Please help me out in this problem.

2
Can anyone please give me a solution on this.. It will be of great help.... - user2783685
Did you make sure you have the latest chromedriver and selenium-webdriver gem? - Justin Ko
Hi Justin.. Below are my environment Details.. I have the updated the gems... selenium-webdriver (2.35.1, 2.29.0).. Chromedriver also is the latest.. - user2783685
Given the html snippet and code you provided, it works fine in Chrome. What is happening on the page that you need to wait for the entityBased element to become present? - Justin Ko
Hi Justin, Both the elements are present.. The element id=filter__EntityBased is a link which performs some operation and the element id=entityBased is an Star Icon next to the link which is used to add the link to the Favorites Pane in our application.Will attach a screenshot of the same... - user2783685

2 Answers

0
votes

I can't comment, sorry.

Have you tried testing with a 5 second sleep, instead of wait until present? From what I could tell, this generally occurs when the javascript reloads the element after the page has loaded.

0
votes

user2783685 I had the same problem and I found solution in stale element reference: element is not attached to the page document So basically javascript reloading element and even I have this on your dom, driver thinking that it's detached. and you need to catch org.openqa.selenium.StaleElementReferenceException may be there is another way, I don't know.