Skip to content
Advertisement

How do I convert this selenium next button clicking code into loop so I can get url of all the pages until next button disappears

Hello I wrote this selenium code to click Next button and give me url of the next page.

The Question is

  1. I want to convert this code in a loop so I can click on the next button & collect all URLs until next button disappears.

  2. How do I out all the collected URLs in a list?

JavaScript

I tried While True loop for this.

JavaScript

I was able to click on the next button until the end but I can not figure out how to collect url of the webpage and how to append them into a list.

Tried append but I think I am doing something wrong.

Advertisement

Answer

You can write a function to test if the element exists:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement