Hi
I want to scrap multiple pages of a website but the next button is not available. I tried
and many more topics but still unable to find the solution. What tried is:
first method:
Used a do-while loop. scraped the data of the first page.
then click on next page using aaname=*
check for element exists for next page.
next page exists = true in while condition.
In this case, it scraps the first page then move to the second page and again come back to the first page. It got stuck in the loop until I force quit it.
second method
I used a do-while loop. scrap the first page then added a counter as pagecount stating with 2
click next page with aaname=pagecount.tostring and then increment the counter.
In this case getting an error as “selector not found” for click activity
Increment the counter
while condition is same as previous.
third method
NextLinkSelector
in this I gave selector with aaname =* but again it got stuck in the loop of the first and second page.
please suggest me if there is any general solution.
I will assume that you mean it’s there but you can’t find a reliable selector for it.
so here is how you can tweak the selector:
Add * to your properties one by one and see if this solves the problem
Eliminate properties one by one
check parent selectors and try it, if it doesn’t work keep go up until you find the one
this is all I can say giving the fact that I don’t have the website, every selector is different so you have to find the one appropriate for your case.
Thanks @reda
I will try your options to get the stable selector.
I mean is that my page do not have arrow or a button where I can click to go to next page. The page only have a list of pages as 1 2 3 and so on not any “>” to move to next page.
Thanks again for your help.
can you share a screenshot from uiexplorer pointing to page 2 link and page 3 link?
Something like below. Make sure the property explorer is pinned and displays the values.
Awesome! Now you can create a dynamic selector with the page number.
Say if your page number is stored a variable pageNo. The selector would be : "<html app='chrome.exe' url='*172.16.105.80*' /><webctrl aaname='" + pageNo.ToString + "' parentid='pagination' tag='A' />"
You can use this selector with Element Exists activity. If it returns true, then you can use the same selector to click on the page. Continue with your data scraping as done in page 1!
I faced with a similar problem a few days ago. I spent a lot of time but finally solved it.
Here is how;
I found an ui element which has the table’s id as parentid for example table_id = asdf_1234-t, elements_parentid = asdf_1234-div …
At first I tried to get a selector value for the table which doesn’t differentiate but could not find.
And then I found that element has table’s id as its parentid and I could reach that element with the constant attributes.
I used “Find element tool” with the constant selector of the ui_element.
finally, with “get attribute” I got the parentid of the found UI element. Changed it with string operations from asdf_1234-div to asdf_1234-t. And defined the selector outside as string. It worked!
You may use this approach. Trust me I spent a lot of time on it
Data Scraping : Scrape from Page and store / process the scraped data as per your scenario
AssignpageNo = pageNo + 1
Element Exists - Target Selector : "<html app='chrome.exe' url='*172.16.105.80*' /> <webctrl aaname='" + pageNo.ToString + "' parentid='pagination' tag='A' />"
Save the result in a boolean variable nextPageExists