Selenium VBA Stale element reference chromebrowser

adinev

New Member
Joined
Nov 10, 2022
Messages
12
Office Version
  1. 365
Platform
  1. Windows
I am currently automating several procedures on a webpage using selenium type library in excel. Currently i am facing the following issue: my code finds a table is supposed to click on each row , do some other things,come back to the page in the table and proceed with the next row. The issue is that after coming back from the first interaction it displays a Stale element reference error. I tried to extend the application wait time, do a retry loop until element is interactable, refreshing the page -all of those did not work. Can someone with exp. help. Here is the snippet of code that errors out

VBA Code:
Dim table, tRow As WebElement

 Set table = driver.FindElementByXPath("/html/body/div[2]/div[2]/div[2]/div[2]/div/div/div[2]/div[1]/table/tbody")


 
 
 Set tRow = driver.FindElementByTag("tr")
 
For Each tRow In table.FindElementsByTag("tr")


            tRow.Click  ''''HERE I GET THE STALE ELEMENT REFERENCE ERROR
            driver.FindElementByCss("#tabs > li:nth-child(9) > a").Click
            Application.Wait Now + TimeValue(pause1)
            driver.FindElementByCss("#breadcrumbs > ul > li:nth-child(1) > a").Click
            Application.Wait Now + TimeValue(pause1)
     
 
            Next tRow
Application.Wait Now + TimeValue(pause1)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,223,877
Messages
6,175,138
Members
452,614
Latest member
MRSWIN2709

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top