I am trying to access a certain row based on the column data and then click the link in that row. How do I achieve this? I've been stuck on this for 5 days.
I am new to Selenium but I have tried looping through the list of elements but then would get a StaleElementReferenceException: stale element is not attached to the DOM.
I saw on the selenium website and a few other questions similar to this that it means the element or the page has updated so the reference to that element may not be correct so I've tried a few things:
I tried using Expected Conditions refresh and then reinitialized the element but that only worked sometimes and i would still get the error I've tried adding a try and catch but that didn't seem to work and I'm also not entirely show if I did it correctly.
I also wanted to see if I could ditch the for loop all together and just find an element in the list that had the 3 attributes that I needed using selenium's "contain" but I'm not sure if that's even something it can do
The Structure of the table is as follows:
<div _ngcontent-c9 class="no-wrap" id="SummaryList">
<div class="row">
<div class="col">
<a>Some Text</a>
</div>
<div class="col">
Value1
</div>
<div class="col">
Value2
</div>
<div class="col">
Value3
</div>
</div>
<div class="row">
<div class="col">
<a>Some Text</a>
</div>
<div class="col">
Value1A
</div>
<div class="col">
Value2B
</div>
<div class="col">
Value3C
</div>
</div>
</div>
The function giving me issues -pseudocode
public void validateInfo(String val1, String val2, String val3){
List<WebElement> rowDetail = driver.findElements(By.xpath("//*[@id=\"SummaryList\"]/div/div"));
int rowSize = rowDetail.size();
for(int i = 0; i<rowSize; i++){
rowDetail = driver.findElements(By.xpath("//*[@id=\"SummaryList\"]/div/div"));
//if row values equal to val1,val2&val3
//then click the a tag in that row and break
}
}
I expect to find the correct row with the 3 parameters passed in and click on the a tag in that row to move on to the next step.
Error: org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document