I am trying to get a element in a list by specifying index
For example I have this xpath:
"//p-dropdown[@formcontrolname='PrimaryRoleId']//ul[contains(@class, 'ui-dropdown-items')]//li[contains(@class, 'ui-dropdown-item')]" and it gives me this:
But when I add [1] at the end of xpath I still get the same thing? How can I get the first (or specific matching element by index)?
CodePudding user response:
Can you try to enclose it with parenthesis "()"
(//p-dropdown[@formcontrolname='PrimaryRoleId']//ul[contains(@class, 'ui-dropdown-items')]//li[contains(@class, 'ui-dropdown-item')])[0]