I have a script that runs through a site checkout flow, and then compares the values for each line item/fee before the order is placed (order summary) and after the order is placed (order confirmation). I have six values that get grabbed by WebUI.getText(), all on the same page and mostly within the same table. Four of that six have no issue, but the text for “Subtotal” and “Order Total” are being read as “” (no value), but the rest of the values are read just fine. My initial thought was that the locator for those two values were not correct, but that didn’t work out.
This had been working flawlessly a few weeks ago, but then the developers took it back to make additional changes elsewhere, and there has been a few Chrome updates since then. I also tried running it on other browsers with the same result. Any ideas?
nth-of-type(5) landed on the taxes field, but it’s easy enough to point in the right spot.
They’re all returning their visible values in DevTools console. Should I slot that code into my method somewhere or just replace the locator in the object?
This XPath expression selects a <p> element which is just next to <p>Subtotal</p>which is inside <div class="order-summary-section"> in the target HTML document. However here I assume that there is only one <p>Subtotal</p> in the document.
If you want to learn more about XPath following-sibling axes, read this artile.
These expressions do not depend on the relative position of the parent node <div class="line-item"></div>. The relative position (5) of the parent node tends to change when the Web page is redesigned. These expressions rather use the text Subtotal as the key to identify the data item you want ($1.00).
A human-visible text (such as Subtotal) in a Web page tends to be sustained/unchanged when the Web page is redesigned. So the above expression could be a bit more robust against the HTML change.