Check if the address has been applied to “Your Store”
I’m trying to figure out how to get a text (store location) from the below HTML tag, store it in a variable and then check if the address (at the “Your Store”) has received the selected address.
This is the tag: 1700 2ND AVE
What I did already:
${Your Store 1}= Get Text //span[@ng-bind=“storeLocation.Address.Street”][@class=“ng-binding”]
Page Should contain ${Your Store 1}
To finish, I noticed that the variable is getting a space only and is passing the test with a false-positive result.
That you are getting a value means the locator you have is “working”. Whether or not it is the right element for the text could still be in question but without seeing the DOM it looks valid enough. (It maybe a bit redundant with the [@class="ng-binding"] but again can’t tell for sure without the DOM). My next guess/ trouble shooting tool would be see if there is a timing issue with some previous action and the page/ angular rending the text. I’d recommend temporarily putting in a 3 to 5 seconds sleep just before the Get Text keyword and see if that changes the behavior/outcome. If it does and the expected text from the locator you have then I would strongly suspect a timing issue (although it still could be something else).
Hey Ed,
First of all, thanks for helping me.
I’ve added the 5s of sleep already but didn’t fix it.
In addition, I need to store the address in the variable to validate in the next step.
You have the address stored there in the ${Your Store 1} variable. Not that variable will have a a scope or “usage” local to that section; be it a test case or keyword … can’t tell from the information given. So you should be able to check against ${Your Store 1} within the local section of the Get Text line. If you need that address outside of that local scope there are various techniques one can use.
No, currently Robot Framework only allows one keyword per line (for the most part). I was trying to respond to your note that “[you] need to store the address in the variable to validate in the next step”. As far as I can see you are doing that and that it appears you are just not getting the text from the element you expect.
As the sleep had no affect my next debug step would be to verify the locator. I see that you have a few screenshots of this but from my experience using the Find tool of the Element tabs is problematic and one I personally don’t trust nor use. I would verify the locator and it’s uniqueness under the Console Tab using the technique outlined under this part of the answer. Note the larger accepted answer also mentions the Find tool but again I don’t use that.
Also it might be that the element you are locating is a span, an inline element, instead of a block-level element, like td [terminology reference]. I see it worth trying the whole cell or and see what text if any is returned. If that brings back text no problem then I would go the path of getting that and parsing out the address.