Dynamic xpath for website

Hi all,

I could not get the product names from this website successfully.
https://www.lazada.sg/catalog/?q=robot+vaccum&_keyori=ss&from=input&spm=a2o42.home.search.go.654346b5JyGWcy

I have followed the work fusion guide and set the counters for the dynamic paths. So i am wondering what went wrong.

I could only get the first product name (from the first web element action) but seems like my for each action did not work. I copied the counter variable on my clipboard and got 40. But the 39 product names were not extracted.

No error messages were thrown as well.

Would appreciate if anyone can take a look. Thanks!

1 Like

In the loop, you save the product names in the same variables, so in each new loop the new name overwrites the previous one.

If you want to save all names, you need to add another action that will push each name to a list variable, so at the end of the execution you will get a list of 40 elements.

3 Likes

Hi,

This is great, it is working now. I just have 1 more question.
The website has more than 40 elements. Is there a way to get all the elements?

Thanks!

1 Like

Glad it helped :slightly_smiling_face:

You can save the list to an .xlsx file using action Set cell value action in a For Each loop as shown in this video

https://player.vimeo.com/video/225055286

Sure, For Each loop will repeat the actions for each element that you have in ${pathlist}. So if there are more than 40 elements, it will get more values than 40.

2 Likes

How about using a table? I tried to append the product and price list to a table and save it

image

But i got product then price in the same column and not product for A column and price for B column.

In the expression action, you can choose whether to append as a row or as a column.

Yes i did try both options.
One gave me the previous picture and the other gave me this

Am i looping it wrongly?
image

You push all value to one list, that’s why you only have 1 row or column in the end.

In this case, you need to have 2 lists, and then push both lists to a table.

2 Likes

Oh yes. Missed out on that. Thanks again. Working as intended :slight_smile:

2 Likes