【问题标题】:Python with selenium: invalid(?) warning带有硒的 Python:无效(?)警告
【发布时间】:2014-08-18 11:30:22
【问题描述】:

使用 python 和 selenium,代码片段:

  alert = driver.switch_to_alert().accept()

通过运行代码,我得到:

  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

这个我不明白,我刚才不是用了driver.switch_to.alert吗?

【问题讨论】:

    标签: python selenium


    【解决方案1】:

    仔细查看调用的名称 - 一次是带下划线的,一次是中间的点。您正在使用 driver 对象的 switch_to_alert() 方法 - 似乎 Selenium 已弃用此方法以支持单独的 switch_to 子类/属性。

    所以你应该使用alert()switch_todriver 的方法, 但您使用的是switch_to_alert()driver

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-10
      • 1970-01-01
      • 2022-01-15
      • 2022-09-30
      • 2019-05-05
      • 2020-09-26
      • 1970-01-01
      相关资源
      最近更新 更多