Quality Testing

Quality is delighting customers

Please suggest how to handle selenium stale element exception

Please suggest how to handle selenium stale element exception

Views: 23

Reply to This

Replies to This Discussion

Hi Ravi,

According to software testing company ,Stale Element Exception is caused when we are unable to get the expected element in the DOM.

Major causes of Stale Element Exception:-

  • Element that you are searching for was present in the DOM before but now it has been deleted from the DOM.
  • Driver Control is shifted to child window and we are trying to access an element that is present on the parent window.


Now , to handle such behavior we can apply any of the following strategies:-

  • The most common mistake due to which Stale Element Exception occurs is trying to access a parent window element when the control has actually been shifted to the Child window. Here we need to make sure that the element you are searching is on the same page where the current control of the driver is which means that if by any chance you have opened a child window and shifted the control to that window, then you won't be able to access the elements from the parent window.
  • Try to refresh the page any then try searching the element again.
  • Place the driver interaction code in try/catch block with multiple attempts using for loop. So in that case, the test case would not fail abruptly.

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2020   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service