ti01878
ti01878

Reputation: 483

Python with selenium: invalid(?) warning

Using python with selenium, fragment of the code:

  alert = driver.switch_to_alert().accept()

By run the code, i get:

  Warning (from warnings module):
  File "C:\Python34\selenium\webdriver\remote\webdriver.py", line 517
  warnings.warn("use driver.switch_to.alert instead", DeprecationWarning)
  DeprecationWarning: use driver.switch_to.alert instead

I dont understand this, Didn't i just use driver.switch_to.alert?

Upvotes: 0

Views: 1796

Answers (1)

stuXnet
stuXnet

Reputation: 4349

Take a closer look at the name of the call - once it's written with an underline, once with a dot inbetween. You are using the method switch_to_alert() of your driver object - it seems like Selenium has deprecated this method in favor of a seperated switch_to subclass / property.

So you should use the method alert() of switch_to of driver, but you are using switch_to_alert() of driver.

Upvotes: 1

Related Questions