We have an e-commerce IPad application where we have to add items in a cart. We can add any number of items. We need to create a reusable sequence where it can fetch the details of each of the item(irrespective of how many items are added in the cart) like Item name, Item description, Item code, Item Price, Item quantity and then customer details, Payment information, Transaction summary in the page.
My Approach was to find the Ui tree structure of all the elements of the page and then iterate over the cart item elements to fetch the details but I do not find any activities through which we can perform this action in UiPath mobile activities.
Could you please let us know what could be the best approach to automate this scenario?
I have uploaded a screenshot of the application page to be automated.
Mobile Automation for number of data elements.docx (532.6 KB)
Thanks and Regards,
Milind Kumar
Ideally you need to get the selector of one item then dont use innertext kind of attrubutes which are specific to the item and then use idx to get all the items one by one
Cheers
HI Anil,
How we will know how many items are added in the cart?
You said not to use innertext and only to rely on idx? Is using idx is the reliable solution? Do we need to pass idx value somewhere?
Is there any other way for this Ipad application automation?
Thanks,
Milind Kumar
I will suggest to use For Each UI element activity to iterate through each item in the cart.
Inside this loop you can use get attribute activity to get the details of the product.
first you need to find other common attributes for items alone then idx can be used as it would be sequential and once the items end the idx wont recognize and that is your stop to check for items
I asked not to use innertext becasue the items can be different
for example your selector can be like this
<webctrl tag='LI' class='Items-class' idx='1' /> - this would be for first item
this is just an example actual selector will differ
@ashokkarale - I doubt if those activities are supported on mobile automation
cheers
You are right @Anil_. I missed the mobile automation tag. Thanks for highlighting this.
@ermilindkumar, ignore my solution as it’s applicable for web automation.
HI Anil, The get text mobile activity if we are using wild card,(*) to get the price or itemcode dynamically, it is not working and giving error message. It says validation cannot be performed if the current selection is invalid.
If we run the get text activity with providing wildcard it throws error as it could not find that specific element. We are also using anchor but still does not work.
UiPath_Mobile.docx (1.7 MB)
Do we have any solution on how to get the text value dynamically? I have attached the screenshot as well for the reference.
use other attributes and dont use wild cards
it supports variables though but not wildcards
cheers
How we will identify the specific element value? Can you see the screenshot and let me know which attributes we can use because the item values will be dynamic and not static?
You should get and share the page source for that screen. Just by looking at a screenshot, is impossible to tell how to construct a potential selector.
HI Cristian, I am attaching the screenshot and the page source which I downloaded. Could you please help how we can construct the selector for Itemcode value- TMWxxxxxx, Price-xx.xx for each item and checkout value-xx.xx.
The wildcard * is throwing error as it is not working. I believe this could be potential issue with UiPath mobile get text activity but not sure.
Ui tree.docx (1.1 MB)
UiTree.xml (29.5 KB)
The hierarchy is pretty flat, so you can’t use the structure to your advantage. So the only solutions, as I see them are (from worse to better from a performance point of view):
- Use idx with a selector of the following
<mbl ios:type='XCUIElementTypeStaticText' idx='2' />
You just do a while with an increasing variable and get all the texts (the loop stops when there is an exception, signaling that nothing was matched - so the current index is out of bounds). Then add the texts to a list and you’ll be able to match by any pattern.
This solution will be super slow though, because each GetText will take 1-2 seconds (if not more). If at any time, there aren’t more than 2-3 products, then this is feasible.
-
A method to improve the previous solution: If you can modify the application, you can add an invisible element with all the info that you need in an attribute and with some id that only these elements share. You’ll still have to use idx for matching just these types of elements but you’ll get everything (ProductId, Price, Checkout Value) in one go, by using GetAttribute activity.
-
Use Appium directly. You can get the session id by using the
Get Session Identifieractivity. Then you can do an API call like the following to search for your elements. You can read more about finding elements at How to Find Elements in iOS (Not) By XPath
POST [appium-url]/session/[session-id-you-got-from-get-session-identifier]/element
Content-Type: application/json
{
"using": "-ios predicate string",
"value": "type == 'XCUIElementTypeStaticText' AND name BEGINSWITH[c] 'TMW' AND visible == 1"
}
If the search is successful you’ll get back a list of elements like the following:
{
"value": {
"element-6066-11e4-a52e-4f735466cecf": "E5090000-0000-0000-420E-000000000000",
"rect": {
"y": 99,
"x": 71,
"height": 21,
"width": 46
},
"ELEMENT": "E5090000-0000-0000-420E-000000000000"
}
}
Then you can use GET calls to get attributes or text:
GET [appium-url]/session/[session-id-you-got-from-get-session-identifier]/element/E5090000-0000-0000-420E-000000000000/attribute/value
GET [appium-url]/session/[session-id-you-got-from-get-session-identifier]/element/E5090000-0000-0000-420E-000000000000/text
HI Cristian, Thanks for the analysis and providing suggestions.
Although I did not try any of the above . Instead I used UiPath Get Page Source activity to get the page source of the cart screen or any other screen where I needed the validation, in the text format. Next I split the text based on the number of items and then for each split text I used Reg-Ex to extract the Item code, Price values etc.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.