When Selenium automates browser window switching, an error is reported: "IndexError: list index out of range"

The window switching method used is:      

handles = self.driver.window_handles
self.driver.switch_to.window(handles[1])

reason:

   When the action of clicking the link to open a new window has not been completed, the code has already started to perform the action of switching the window, resulting in no list data being obtained.

Solution:

   Add a waiting time, wait for the new window to be loaded, and then perform the window switching action.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325832620&siteId=291194637