selenium.common.exceptions.InvalidSelectorException: Message: invalid selector
Unable to locate an element with the xpath expression .//*[@id="Toolbar"]/table/tbody/tr/td[2]/a[1]/span)[3]
because of the following error.
SyntaxError:
Failed to execute 'evaluate' on 'Document': The string
'(.//*[@id="Toolbar"]/table/tbody/tr/td[2]/a[1]/span)[3])'
is not a valid XPath expression.
Alexey R.
11.6k5 gold badges21 silver badges39 bronze badges
asked Aug 8, 2018 at 5:50
-
you will need to provide us with your HTML code too. Please avoid using absolute XpathYu Zhang– Yu Zhang2018年08月08日 05:51:29 +00:00Commented Aug 8, 2018 at 5:51
-
2(.//[@id="Toolbar"]/table/tbody/tr/td[2]/a[1]/span)[3]), you have an extra ")" right after spanYu Zhang– Yu Zhang2018年08月08日 05:52:43 +00:00Commented Aug 8, 2018 at 5:52
-
the xpath has 4 matching node so that [3] requires an extra ")".Ankit Kumar– Ankit Kumar2018年08月08日 05:55:04 +00:00Commented Aug 8, 2018 at 5:55
-
driver.find_element_by_xpath('(.//*[@id="Toolbar"]/table/tbody/tr/td[2]/a[1]/span)[3])').click()Ankit Kumar– Ankit Kumar2018年08月08日 05:55:23 +00:00Commented Aug 8, 2018 at 5:55
-
Try with ((//[@id="Toolbar"]/table/tbody/tr/td[2]/a[1]/span)[3]), there seems to be a syntax error in your xpath.Kshetra Mohan Prusty– Kshetra Mohan Prusty2018年08月08日 06:20:59 +00:00Commented Aug 8, 2018 at 6:20
1 Answer 1
The error shows that the given expression is not valid. You seem to have an extra ')' in the xpath selector at the end. So browser wouldn't have even performed the DOM selection.
answered Aug 8, 2018 at 12:05
-
Since the same xpath has 4 matching node i have used that extra ')' for using the 4th matching node.Is there any another way to do kindly help me with that.Ankit Kumar– Ankit Kumar2018年08月09日 05:00:04 +00:00Commented Aug 9, 2018 at 5:00
-
How does adding an extra ')' help. You should be getting the 3rd span without that ')'.Dakshinamurthy Karra– Dakshinamurthy Karra2018年08月09日 05:08:18 +00:00Commented Aug 9, 2018 at 5:08
Explore related questions
See similar questions with these tags.