How could I find the DOM element once I'm redirect to another page?

21 views
Skip to first unread message

Laurence Lin

unread,
May 18, 2021, 2:05:18 AM5/18/21
to Selenium Users
I'm working on a task, that I could scan all href links of a website and get the data from them.

Now I have the following code:

dwfw.png

Originally I get to the first webpage, and navigate to several links by driver.get(link)

But it seems some link would navigate to external website, and cause the error:
2.png

It seems if the driver navigate to external website, the DOM could no longer find the web elements containing the links I set before the loop.

How could I deal with the problem? A stupid method I'd think of is to get back to the original URL everytime after a link is get by driver.

Thank you for any help!


Reply all
Reply to author
Forward
0 new messages