Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

garvitagirotraev
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cf8ad6a7-38cd-40b5-b266-333473efd1c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

Joe Ward
Without knowing what you're trying to test against or at seeing something like a dump of the DOM at the time that line is executed there's not much we can say that's not generic.

On 5 June 2018 at 06:39, <[hidden email]> wrote:
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cf8ad6a7-38cd-40b5-b266-333473efd1c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAJPyTs3c%2Bq1G03CHU5o5iDHc6PEN2J54PFpZAY0py7asVFg%3D6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

Scott Babcock
In reply to this post by garvitagirotraev
If all you're trying to do is extract text from a collection of elements, I recommend using a bit of JavaScript instead. You can get the entire set of values (not element references) in a single call, which is much more efficient.

Regardless, stale element reference failures indicate that the page is getting redrawn after you acquire the references. This indicates that the page may occasionally take longer to load, or that the page contains dynamic content that's changing the DOM, which necessitates periodic rebuilding.

On Monday, June 4, 2018 at 10:39:13 PM UTC-7, [hidden email] wrote:
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/92bf7643-83a9-49d0-90d7-e127e4fb93f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

Scott Babcock
In reply to this post by garvitagirotraev
Alternatively, you could use my Selenium Foundation framework and make stale reference failures a thing of the past. This would require switching your tests to a new framework, which may be more effort than you're ready to expend, but you'll never see another stale reference "noise" failure like you're fighting now.

On Monday, June 4, 2018 at 10:39:13 PM UTC-7, [hidden email] wrote:
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/bdcdeba6-8bfa-4d9f-aec1-e49e271ea0d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

total QA
In reply to this post by garvitagirotraev
Hi,
Please find the solution for the issue as follow:

for (WebElement we : list) {
           
            set.add(we.getText()); 
           //Please add this line after add
           list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
        }

For advanced reporting for your project please refer to the links below:
http://total-qa.com/advanced-selenium/allure-reporting/
http://total-qa.com/extent-reports-selenium-webdriver/

Regards,
total-qa.com.

On Tuesday, June 5, 2018 at 11:09:13 AM UTC+5:30, [hidden email] wrote:
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/48592bb3-7197-40ce-941b-eebb82efccb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

garvitagirotraev
In reply to this post by Scott Babcock
Hi Scott,

Thanks for providing framework reference. I will have a look and will switch as i would surely not like to see these exceptions in long run.

Thanks !!

On Wednesday, June 13, 2018 at 10:04:11 AM UTC+5:30, Scott Babcock wrote:
Alternatively, you could use my <a href="https://github.com/Nordstrom/Selenium-Foundation" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNordstrom%2FSelenium-Foundation\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdcpQcQWvEXWh_rWtyqSaXrQc7DQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNordstrom%2FSelenium-Foundation\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdcpQcQWvEXWh_rWtyqSaXrQc7DQ&#39;;return true;">Selenium Foundation framework and make stale reference failures a thing of the past. This would require switching your tests to a new framework, which may be more effort than you're ready to expend, but you'll never see another stale reference "noise" failure like you're fighting now.

On Monday, June 4, 2018 at 10:39:13 PM UTC-7, [hidden email] wrote:
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

vamsi naga
I believe when the network/browser is slow in performance you are getting this error. Before the page fully load, you are retrieving the list of elements and when you are trying to retrieve the text of those elements you are facing the issue. Try to wait till the page loads, using some external waits and try to retrieve the elements.

Hope it works

Thanks ... Vamsi 

On Mon, Jun 18, 2018 at 11:14 AM, <[hidden email]> wrote:
Hi Scott,

Thanks for providing framework reference. I will have a look and will switch as i would surely not like to see these exceptions in long run.

Thanks !!

On Wednesday, June 13, 2018 at 10:04:11 AM UTC+5:30, Scott Babcock wrote:
Alternatively, you could use my Selenium Foundation framework and make stale reference failures a thing of the past. This would require switching your tests to a new framework, which may be more effort than you're ready to expend, but you'll never see another stale reference "noise" failure like you're fighting now.

On Monday, June 4, 2018 at 10:39:13 PM UTC-7, [hidden email] wrote:
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
Naga Vamsikrishna Vaka.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CA%2B0fjuPW-RUqy3s3cTZpH3YfH2EKPNsQPPqG7oXoPXEN0LomPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

total QA
Hi,

you can even call findElements and insert a wait on it. This would be helpful. Else else get the focus of the element which is in the bottom of the page as mentioned below:

              new Actions(driver).moveToElement(WebElement);

Regards,



On Monday, June 18, 2018 at 11:24:24 AM UTC+5:30, vamsi naga wrote:
I believe when the network/browser is slow in performance you are getting this error. Before the page fully load, you are retrieving the list of elements and when you are trying to retrieve the text of those elements you are facing the issue. Try to wait till the page loads, using some external waits and try to retrieve the elements.

Hope it works

Thanks ... Vamsi 

On Mon, Jun 18, 2018 at 11:14 AM, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="3XKKOvb5BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">garvitag...@...> wrote:
Hi Scott,

Thanks for providing framework reference. I will have a look and will switch as i would surely not like to see these exceptions in long run.

Thanks !!

On Wednesday, June 13, 2018 at 10:04:11 AM UTC+5:30, Scott Babcock wrote:
Alternatively, you could use my <a href="https://github.com/Nordstrom/Selenium-Foundation" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNordstrom%2FSelenium-Foundation\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdcpQcQWvEXWh_rWtyqSaXrQc7DQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNordstrom%2FSelenium-Foundation\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdcpQcQWvEXWh_rWtyqSaXrQc7DQ&#39;;return true;">Selenium Foundation framework and make stale reference failures a thing of the past. This would require switching your tests to a new framework, which may be more effort than you're ready to expend, but you'll never see another stale reference "noise" failure like you're fighting now.

On Monday, June 4, 2018 at 10:39:13 PM UTC-7, [hidden email] wrote:
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="3XKKOvb5BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="3XKKOvb5BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Regards,
Naga Vamsikrishna Vaka.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c415bbd1-690d-47fe-b211-dd9f7f702307%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

garvitagirotraev
In reply to this post by vamsi naga
Hi Vamsi,

I added wait until all elements in  list are visible , it did not work too. 

Thanks,
Garvita 

On Monday, June 18, 2018 at 11:24:24 AM UTC+5:30, vamsi naga wrote:
I believe when the network/browser is slow in performance you are getting this error. Before the page fully load, you are retrieving the list of elements and when you are trying to retrieve the text of those elements you are facing the issue. Try to wait till the page loads, using some external waits and try to retrieve the elements.

Hope it works

Thanks ... Vamsi 

On Mon, Jun 18, 2018 at 11:14 AM, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="3XKKOvb5BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">garvitag...@...> wrote:
Hi Scott,

Thanks for providing framework reference. I will have a look and will switch as i would surely not like to see these exceptions in long run.

Thanks !!

On Wednesday, June 13, 2018 at 10:04:11 AM UTC+5:30, Scott Babcock wrote:
Alternatively, you could use my <a href="https://github.com/Nordstrom/Selenium-Foundation" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNordstrom%2FSelenium-Foundation\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdcpQcQWvEXWh_rWtyqSaXrQc7DQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNordstrom%2FSelenium-Foundation\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdcpQcQWvEXWh_rWtyqSaXrQc7DQ&#39;;return true;">Selenium Foundation framework and make stale reference failures a thing of the past. This would require switching your tests to a new framework, which may be more effort than you're ready to expend, but you'll never see another stale reference "noise" failure like you're fighting now.

On Monday, June 4, 2018 at 10:39:13 PM UTC-7, [hidden email] wrote:
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="3XKKOvb5BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="3XKKOvb5BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Regards,
Naga Vamsikrishna Vaka.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd90b47b-cd3f-490e-9945-247e61ac6e65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Not able to fix stale element exception - :Linux/Chrome 66/Chromedriver 2.37(Urgent)

garvitagirotraev
In reply to this post by total QA
I tried both solutions, nothing is working.

I tried below too :

1. Ignoring stale element exception till gettext() is true:
WebDriverWait wait = new WebDriverWait(getDriverInstance(), 10);
            wait.ignoring(StaleElementReferenceException.class).until(
                    new ExpectedCondition<Boolean>() {
                        public Boolean apply(WebDriver driver) {
                            System.out.println("inside wait condition");
                            pathPatents.add(ele.getText());
                            return true;
                        }

2. Get text, not reference and find element in loop for first time
int patentlist = driver.findElements(By.cssSelector("ul#doc-list a.text-title"))
for(int i = 1; i <= patentlist; i++) {
            String locator = String.format(prop.getProperty("patentNo_CSS"), i);
            WebElement cell = driver.findElement(By.cssSelector(locator));
             pathPatents.add(cell.getText());
        }

Thanks,
Garvita
On Monday, June 18, 2018 at 12:08:06 PM UTC+5:30, total QA wrote:
Hi,

you can even call findElements and insert a wait on it. This would be helpful. Else else get the focus of the element which is in the bottom of the page as mentioned below:

              new Actions(driver).moveToElement(WebElement);

Regards,
<a href="http://total-qa.com." target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftotal-qa.com.\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWa0WL-Fd1gY7nWpB5OZ7ogBZX7w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftotal-qa.com.\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWa0WL-Fd1gY7nWpB5OZ7ogBZX7w&#39;;return true;">total-qa.com.



On Monday, June 18, 2018 at 11:24:24 AM UTC+5:30, vamsi naga wrote:
I believe when the network/browser is slow in performance you are getting this error. Before the page fully load, you are retrieving the list of elements and when you are trying to retrieve the text of those elements you are facing the issue. Try to wait till the page loads, using some external waits and try to retrieve the elements.

Hope it works

Thanks ... Vamsi 

On Mon, Jun 18, 2018 at 11:14 AM, <[hidden email]> wrote:
Hi Scott,

Thanks for providing framework reference. I will have a look and will switch as i would surely not like to see these exceptions in long run.

Thanks !!

On Wednesday, June 13, 2018 at 10:04:11 AM UTC+5:30, Scott Babcock wrote:
Alternatively, you could use my <a href="https://github.com/Nordstrom/Selenium-Foundation" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNordstrom%2FSelenium-Foundation\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdcpQcQWvEXWh_rWtyqSaXrQc7DQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FNordstrom%2FSelenium-Foundation\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdcpQcQWvEXWh_rWtyqSaXrQc7DQ&#39;;return true;">Selenium Foundation framework and make stale reference failures a thing of the past. This would require switching your tests to a new framework, which may be more effort than you're ready to expend, but you'll never see another stale reference "noise" failure like you're fighting now.

On Monday, June 4, 2018 at 10:39:13 PM UTC-7, [hidden email] wrote:
Hi,

Suddenly i have starting hitting stale element exception for below scenario:

1. Getting element in list :
List<WebElement> list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
It return list of 4 elements.

2. getText() from list elements and add to set.
 Set<String> set = new HashSet<String>();

for (WebElement we : list) {
            set.add(we.getText());  // i am hitting stale element on this line always.
        }

Solutions tried :
1. Load list again before getting text
for (WebElement we : list) {
            list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
            set.add(we.getText()); 
        }

2. get list element in loop in case list is not loaded completely. 
for(int i=0;i<5;i++)
{
       list = driver.findElements(By.cssSelecto("ul#doc-list a.text-title"));
}

3. Add text from list element in another list, then add to set. 
List<String> text = new ArrayList();
for(WebElement s : list)
{
  li.add(s.getText();
}


Nothing worked at all. This stale element exception is not consistent, 2 times it runs successfully next time it hits error. This exception occurs only running in CI, on local i never hot it so i am not bale to debug it. It all started after upgrading to chrome 66.

Anyone has any solution to this, please advice same.

Thanks !!



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/2cba3a6a-db5c-48bf-b839-f6efd6fa4840%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Regards,
Naga Vamsikrishna Vaka.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f3968fe0-1647-4e7f-961c-456da4efe7b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.