How to get nth attribute of a page element
I'm trying to get data of an element's second attribute. For example, I have something like this: <div class = "XYZ" data-json="{ "componentname":"ABCD","orderID":"1234",.....}"
I need orderID from the above page element.
I tried the following:
put FindElement(WebXPath:"//*[@id='main']/div[2]/div")'s "data" & numToChar(45) & "json" --> Throws an error that DATA-JSON property isn't found.
I need orderID from the above page element.
I tried the following:
put FindElement(WebXPath:"//*[@id='main']/div[2]/div")'s "data" & numToChar(45) & "json" --> Throws an error that DATA-JSON property isn't found.
Tagged:
Comments
// Get the page source of the current webpage and set it as an XML tree
put the webdriver's pageSource as tree into x
// Traverse through the tree to reach the tag you have the attribute you are looking for
// get the data-json attribute from the tag. "data-json" isn't recognized directly so I have used ASCII value
// My order ID is the 5th json value of the whole json response
// Split the order ID by " : " and " " ". Again, use ASCII values when eggplant can't recognize certain characters