【发布时间】:2022-01-18 10:12:55
【问题描述】:
我正在尝试使用 Python selenium webdriver 切换到新打开的窗口。该代码以前运行良好,但现在显示错误。令人惊讶的是,switch_to_window() 方法没有被 Python 识别并且没有声明可以去。
def process_ebl_statements(self, account_number):
current_window = self.driver.current_window_handle
all_windows = self.driver.window_handles
print("Current window: ", current_window)
print("All windows: ", all_windows)
number_of_windows = len(all_windows)
self.driver.switch_to_window(all_windows[number_of_windows - 1])
错误详情:
'WebDriver' object has no attribute 'switch_to_window'
【问题讨论】:
-
The code worked fine before和but now it is showing error之间发生了哪些变化? -
还有 driver.switch_to_window 被折旧使用 driver.switch_to.window
-
stackoverflow.com/questions/57567464/… 也可以使用新窗口。
标签: python selenium selenium-webdriver webdriver webautomation