Find all elements of a certain class on a page

Hello,

I’m currently trying to save a series of links to a csv. However, they are all scattered over the page with different html nesting.

Formerly, my approach was to identify the nesting pattern and locate the element via css + the Loop variable (e. g. css=table tbody tr:nth-of-type(${!LOOP}) td a). However this method is not working anymore since the nesting and elements change.

Is there a way to find elements of the same class everywhere on the page and go through them one by one?

How do they change now?

Some are in a table. Some are in a blockquote. Besides that the element itself stays the same (a with a class).

Post url of page please

Sorry, can’t do that. Its a private backend. However, this is what I mean:

Table cell with a link Table cell
Table cell Table cell

Test text with a link

I cannot scrape the links href one after another because my locator (e.g. target:nth-of-type(!LOOP)) will not find them because they are nested differently

Try to use the command store, after ui vision create a generic xpath and increment this xpath.

Without see the page is impossible to help you in better way.

Generic xpath is more efficient for table ui vision create it with store command.

Create in ui vision a command store, after click select button and click over the element prefered.

is there a way to add a class into the html via javascript?

I thought about this scenario:

  1. scrape link url from class
  2. insert another class which makes the element not valid for the locator statement anymore
  3. loop this so it always scrapes an url from a link and then makes the link invalid with a new class

Why do you use class to store value ?

Try other better xpath