Support Portal

for ProcessRobot and WinAutomation

Start a new topic
Answered

Loop CSS-Selectors - Click button on webpage

 Hi,


im trying to programm a bot to go to ebay, search for a certain product, click on the first search result, return to the search, click on second, aso.


i know i can simply extract the links as list and open them one by one but i need to be able to loop the controls/css-selectors for a click button on webpage action, since this is just a test run and in the actual project it needs to work like this.


Here are the first 2 CSS-Selectors Processrobot extracted from the ebay list.

Note each Button contains 2 selectors.


Link1:
body > div:eq(4) > div:eq(1) > div:eq(0) > div:eq(0) > div > div:eq(1) > div > div:eq(2) > div > div:eq(0) > div > custom > div > div:eq(1) > ul > li:eq(0) > h3 > a

li[id="item592d9a294b"] > h3[class="lvtitle"] > a[class="vip"]


Link2:

body > div:eq(4) > div:eq(1) > div:eq(0) > div:eq(0) > div > div:eq(1) > div > div:eq(2) > div > div:eq(0) > div > custom > div > div:eq(1) > ul > li:eq(1) > h3 > a

li[id="item5d84637804"] > h3[class="lvtitle"] > a[class="vip"]


My plan was to insert a loop varablie into the element on the right hirachie level: li:eq(%Loopindex%), but that doesnt seem to work.


it seems the real (working part of the) CSS-Selectors of the buttons are

li[id="item5d84637804"] > h3[class="lvtitle"] > a[class="vip"]

li[id="item592d9a294b"] > h3[class="lvtitle"] > a[class="vip"]


and since its an individual ID i dont know how to automate this. Why doesnt the first Selector work?


Any ideas for a workaround??


Thanks alot!


Best Answer
As per my observation, the CSS selector that you attempted is not unique and the unique CSS selector that you need to select is as below.


ul[id="ListViewInner"] > li[r="%LoopIndex%"] > h3[class="lvtitle"] > a[class="vip"]



The reason behind this is you can check the CSS of your site by inspecting, From that, we observed that 'r' value under "li" is dynamic and we need to change that every time for a new item. Below screenshot is from DOM explorer after inspecting your site.


ADMIN

Hi Alexander try using below CSS- Selector,


body > div:eq(4) > div:eq(1) > div:eq(0) > div:eq(0) > div > div:eq(1) > div > div:eq(2) > div > div:eq(0) > div > custom > div > div:eq(1) > ul > li[id^="item"]:eq(%LoopIndex%) > h3 > a.


Here li[id^="item"] represents that id can start with item keyword.


I hope the above helps you.

Hey Ramakrishna,


thanks for comment! unfortunetaly that doesnt work either.I deleted the second selector and my first one looks like this now:


body > div:eq(4) > div:eq(1) > div:eq(0) > div:eq(0) > div > div:eq(1) > div > div:eq(2) > div > div:eq(0) > div > custom > div > div:eq(1) > ul > li[id^="item"]:eq(%LoopIndex%) > h3 > a


Now Process robot doesnt open any Product at all (Element not found).

Is the ^ in id^ on purpose?


Any other ideas?


Thanks!

ADMIN
Answer
As per my observation, the CSS selector that you attempted is not unique and the unique CSS selector that you need to select is as below.


ul[id="ListViewInner"] > li[r="%LoopIndex%"] > h3[class="lvtitle"] > a[class="vip"]



The reason behind this is you can check the CSS of your site by inspecting, From that, we observed that 'r' value under "li" is dynamic and we need to change that every time for a new item. Below screenshot is from DOM explorer after inspecting your site.

Hello, I have the same issue that's why I'm writing here.


In the page where I want to extract data, I can\t make the loop for the next page.


The site is: https://www.ekatte.com/%D0%B0-%D1%8F/%D0%B1?page=1


The problem is, when I extract selector, LI number is not same or increased with one in the next page.


On first page link is:  

html > body > div:eq(1) > div > div:eq(1) > div > div > div > div:eq(1) > div > section > div > div > div > div:eq(2) > ul > li:eq(5) > a

 Next page is:   

html > body > div:eq(1) > div > div:eq(1) > div > div > div > div:eq(1) > div > section > div > div > div > div:eq(2) > ul > li:eq(10) > a

 

The text for the next page is always the same "Следваща", but how to make to click on it? 


Any advice is welcomed

Login or Signup to post a comment