suebius
February 19, 2023, 11:06am
#1
I am new to ui.vision and I try to get a better understanding for the use of xpath.
As an example, I want to store all items containing the text “Label” on a website.
So I used the storeAttribute command with the following target:
xpath=//*[contains(text(),‘Label’)]
However, the script returns the error message
“invalid target for storeAttribute - xpath=//*[contains(text(),‘Label’)]”
Where is my error? The xpath I used seems to be identical to examples I found for the Selenium IDE.
Any help is really appreciated.
You must add the attribute to store example @href
xpath=//*[contains(text(),‘Label’)]@href
Here info
https://ui.vision/rpa/docs/selenium-ide/storeattribute
suebius
February 19, 2023, 4:04pm
#3
Thank you so much.
But now I get the error message “missing attribute ‘href’”
Storeattribute extracts only available attributes, in your case href is not available. You can extract only the attributes available in the html code
https://ui.vision/rpa/docs/selenium-ide/storeattribute
suebius
February 19, 2023, 5:06pm
#5
But is there an easy way that XPATH just returns those objects which have the property “href”?
Like all <a or all <div which include a URL?
uiuser
February 20, 2023, 2:17am
#6
suebius:
href
Only Tag A has href attribute
suebius
February 20, 2023, 5:11pm
#7
But how can I restrict the expression so that only anchors which have the property “href” are returned?
Or is there another way how I can handle the error message?
uiuser
February 20, 2023, 8:43pm
#8
you can get all links with this
xpath=//self::a