Note that there are some explanatory texts on larger screens.

plurals
  1. POSelenium- How to check if element is present or not
    primarykey
    data
    text
    <p>Consider the following scenario:-</p> <p>A bookstore website has number of books and each book has some details like author name, publisher, etc. The main page displays number of books and on clicking any book on the page a pop-up opens which displays details of that particular book. The main html page looks something like below.</p> <p> link Book 1 </p> <pre><code>&lt;book id="abc"&gt; &lt;a href="linkAddress"&gt;link&lt;/a&gt; &lt;div class="name"&gt;Book 2&lt;/div&gt; &lt;/book&gt; &lt;book id="abc"&gt; &lt;a href="linkAddress"&gt;link&lt;/a&gt; &lt;div class="name"&gt;Book 3&lt;/div&gt; &lt;/book&gt; &lt;book id="abc"&gt; &lt;a href="linkAddress"&gt;link&lt;/a&gt; &lt;div class="name"&gt;Book 4&lt;/div&gt; &lt;/book&gt; &lt;book id="abc"&gt; &lt;a href="linkAddress"&gt;link&lt;/a&gt; &lt;div class="name"&gt;Book 5&lt;/div&gt; &lt;/book&gt; </code></pre> <p></p> <p>I want to fetch details of all books so what I did is I fetched a list of all the book elements from the main page </p> <pre><code>List&lt;WebElement&gt; items = fireFoxDriver.findElements(By.id("abc")); </code></pre> <p>and then iterated through that list and clicked each element one by one to open a pop-up that shows details of the book</p> <pre><code>for(WebElement itemDetails : items){ itemDetails.click(); //After clicking the element pop-up opens which shows details of this particular book. //Get details of this particular book from pop-up. } </code></pre> <p>and fetched the details I required from that opened pop-up and then closed the popup after getting all required details and moved to next element.</p> <p>Now the problem is that I am using <code>itemDetails.click()</code> to open pop-up but sometimes I get the following errors when opening a pop-up window. I am not sure how to handle these errors so please guide me. Elements are there on the main page I am not changing the main page while opening pop-up but still getting DOM errors.</p> <ol> <li>org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM</li> <li>com.thoughtworks.selenium.SeleniumException: Timed out waiting for action to finish</li> </ol> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload