Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
280 views
in Technique[技术] by (71.8m points)

java - How can I test EVERY link on the WEBSITE with Selenium

I want to test every link on a WEBSITE. I googled a lot but there were only solutions to test every link on a WEBPAGE.

How I wanted to do it: If the script clicks on a link, the script looks on the new webpage if there is a new link. If there is a new link then the script clicks it and repeats the steps(look and click) untill he cannot find a link. In that case the script navigates back until he finds a new link to click.

Does anyone have a solution for me? I am using Java.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use a recursive function to open a link, findElements by Html tag name , and call the function again for each of these links in the list. Be aware that, this can go on for a while, you might run out of memory etc because all web pages normally have links.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...