Skip to content
Advertisement

Selenium test getting interrupted by a popup

I am trying to run some practice test on this webpage that prints the current positions of teams in this table:

https://www.premierleague.com/tables

but each time i run the script, I keep getting interrupted by a popup that I can’t seem to get Selenium to click.

I have tried adding a wait before clicking, but it keeps returning the same error

JavaScript

This is my code:

JavaScript

Advertisement

Answer

I was able to fix the problem by adding an implicit wait after the finding the element. By asking Selenium to wait until the element appears I was able fix the error. I thinking selecting the element by ID instead of XPath also helped.

JavaScript
Advertisement