Same XPath attribute test for multiple tags
This XPath expression finds all
a elements that contain the text
Let's meet at 9 o'clock:
//a[text()=concat('Let', "'", 's meet at 9 o', "'", 'clock')]
How can I change the XPath expression so that not only
a tags are found but also
Try below XPath:
//*[(name()='a' or name()='div') and text()=concat('Let', "'", 's meet at 9 o', "'", 'clock')]
how to handle if xpath is same for multiple drop down, It might be issue of same level HTML code. Solution : 1. For First Dropdown : (//div[@name='expiryDate']/div/a/div/i). 2. For Second Xpath Match for multiple nodes Hi, I have a situation where I get a set of results elements back, each of which should contain the same birthDate(for example).
self:: axis to check for either
div, plus your other predicate:
//*[self::a or self::div][text()=concat('Let', "'", 's meet at 9 o', "'", 'clock')]
Using Multiple Predicates In The Same Part Of An XPath Query In , @Amith,. Do you mean you need to find any tag that has the attribute "IsSSR=true", regardless of the tag name? In any case THANK YOU VERY MUCH for answers. The attribute doesn't have to be in the root/end of XPath, it can be an attribute of one of the children of the root/end node. That is a exelent answer, thanks. XPath in any data field of *,jrxml. That is a point.
//(a | div)[. = concat('Let', "'", 's meet at 9 o', "'", 'clock')]
CSS & XPath Element Locators: XPath Syntax-3: Tag with multiple , CSS & XPath Element Locators: XPath Syntax-3: Tag with multiple attribute with Duration: 2:20 Posted: Jan 26, 2019 The bullet-points, #1 and #2 are an assumption on the class names used in your HTML, that leads me to think that is some kind of financing application with different information for a specific account that may be displayed by hours, days, weeks, etc, leading to multiple links (a tags) in your table.
Examples with xpath and Css (ID, Name, Text and Links), Identify element using multiple attributes Links have anchor tags, we can apply the same as we applied for 'Text', the only difference here is we should add XPath: Select multiple child nodes. Given the following sample "xml" file (tags won't display correctly, so I used spaces instead of angle brackets. All nodes are elements, no attributes) I can easily select the President nodes of George and Honest Abe.
WebDriver Locating Strategies By XPath Using Multiple Attribute , WebDriver Locating Strategies By XPath Using Multiple Attribute with tool suite, selenium ide, ide-installation, ide-features, ide-first test case, ide-commands, The syntax for locating elements through XPath- Multiple Attribute can be written as: //<HTML tag>[@attribute_name1='attribute_value1'][@attribute_name2=' Mastering XPath and/or CSS is essential for the Selenium test automation engineers to locate dynamic web elements, elements without i ds or names and elements with dynamic ids and names. Tagname is not a useful location strategy to locate elements as there will be many elements with the same tagname.
XPath uses path expressions to select nodes in an XML document. The node is selected by following a path or steps. The most useful path expressions are listed below: Selects all nodes with the name " nodename " Selects from the root node. Selects nodes in the document from the current node that match the selection no matter where they are.
- You're missing the
()on one of those
- @JLRishe. Right. Thanks
- Trying to learn something new here: so if a web element does not have a name attribute, the name is the tagname itself? If so, good to know.
name()is not the same as
@name. If we have something like
<input name="qwerty">, then we can use both
- Thank you for that explanation. I definitely learned something new from that.
- Does this have any advantages or disadvantages compared to the other answer?
- Also useful. Is perhaps this xpath version specific vs. name() ?
- I prefer to use the
self::axis directly (rather than indirectly via a function call that returns a string) as I feel it's a bit more direct and concise expression of intent.