Skip to main content
 首页 » 编程设计

python之函数 driver.switchTo.frame() 在 Selenium 中不起作用

2025年05月04日16tuyile006

当我尝试在 Python 的 selenium 中使用 Webdriver 切换到网页上的框架时,它显示错误。请在下面找到我的代码:

driver.switchTo().frame("frame"); 

AttributeError: 'WebDriver' object has no attribute 'switchTo'

请您参考如下方法:

那是因为您正在使用 Java 方法。在 Python 中你应该使用

driver.switch_to.frame("frame_name")