0

I'm a little dumbfounded by an issue I've been having for a few days now. I keep getting stale element exception from areas in the test in which everything worked flawless before. Even though I presumed that it's due to a slow server I'm running these tests on, unfortunately I am not able to switch or run these tests locally.

Here is a snippet used to mediate the stale element exception. This snippet stopped the process from ending/crashing in a stale element exception, but it won't leave the loop, and my console keeps printing the fact that indeed, there is stale element exception.

Any input is greatly appreciated. Also, if indeed my issue is server side, what workarounds can be implemented?

public void checkSomething() {
        SomeClass someClass = new SomeClass()
        for(int x = start; x <= end; start++) {
            //ignore for loop, it just iterates through a list
            boolean staleElement = true;
            while (staleElement) {
                try {
                    someClass = new SomeClass()
                    staleElement = false
    
                    veriThis()
                    andVerifyTheOther()

                }
                catch (StaleElementReferenceException ex) {
                    println "Stale Element = " + cell
                    println ex.getStackTrace()
                }
            }
            
            
        }

  • Why aren't you breaking from the catch statement? – Arundeep Chohan Feb 17 '22 at 07:40
  • the boolean StaleElement acts as a 'break' for the while, the while continues as long as the boolean is false, if the methods don't work, then the boolean reverts to false and the iteration continues – AppleStrudel Feb 17 '22 at 07:58

0 Answers0