I used a While activity for my data scraping. I added an Element Exists activity before the while activity. I created a variable for the EE as Check.
So in my While activity, my condition is Check = True.
The element by the way is a next button. So, my While activity or loop won’t stop because the EE finds the element as True all the time. The problem here is the next button is already greyed out or not clickable because we are already on the last page. However, Element Exists can’t understand that. It can see the button but not clickable but still EE will still return True. How do I stop this loop so I can just proceed to my Write Range activity?
Please compare selectors for the button when it is grayed and when not grayed.
You should be able to find a css class name or something that indicates the current state of the button that will help differentiate the states of the button.
Therefore, your Robot must look for both types of elements and then use these two elements to validate the Check variable
Theoretically:
eeButton = FindElement(selector for regular button) ' if found will return true
eeGrayButton = FindElement(selector for Gray button) ' at the same time this will be false
When the Button Grays out, the above condition will be reversed.
Check = (eeButton IsNot Nothing) 'Good, continue with Loop
Check = (eeGrayButton IsNot Nothing ) 'No, stop while loop
You can combine these two conditions into an Or and see how it works.
Thanks for giving me such a detailed solution. I will try and figure this out. I am not familiar with coding yet. I am only doing drag and dropping with StudioX Community.
I use Find Element as regular practice. I find it easier to understand because I am trying to find something on a page without pre-determining if it exists or not.
You can write it both ways and contribute your findings here. It would help us all.
Correct, but you are checking if CheckGreyBtn UiElement is a valid object or not. Not whether it is True or not.
Going back to this line:
Check = (CheckGreyBtn IsNot Nothing) . This will return true if your button element is valid.
Try this just for the kicks by setting CheckGreyBtn to Nothing
CheckGreyBtn = Nothing Check = (CheckGreyBtn IsNot Nothing) . This time the result returned is False because you have intentionally destroyed the UiElement.