开发者

How do I verify an xPath expression in Selenium IDE?

开发者 https://www.devze.com 2023-02-05 20:11 出处:网络
How would I test for the following expression in Selenium? not(//select[@id=\'ddlCountry\']/@clas开发者_StackOverflows) or

How would I test for the following expression in Selenium?

not(//select[@id='ddlCountry']/@clas开发者_StackOverflows) or
not(contains(//select[@id='ddlCountry']/@class,'invalidValue'))

true if the class attribute doesnt exist, or if it does, the attribute doesn't contain invalidValue.

I've tried using the verifyElementPresent command, but it errors out, I assume because I'm returning a boolean rather than a node.

I'm happy with an alternative to this if theres no way to do the above using xPath.


In case your XPath engine API doesnt allow expressions returning atomic values (not nodes), then you still can

Use:

//select[@id='ddlCountry'][contains(@class,'invalidValue')]

and test if an element was selected or not.


true if the class attribute doesnt exist, or if it does, the attribute doesn't contain invalidValue.

not(//select[@id='ddlCountry']/@class[contains(.,'invalidValue')])
0

精彩评论

暂无评论...
验证码 换一张
取 消