I am trying to locate this tag with CSS selector inner text
<a href="/introduction-to-selenium.html">1) Introduction</a>
I have used the xpath:
a.contains("1) Introduction")
But its not working. Can anyone help me?
I am trying to locate this tag with CSS selector inner text
<a href="/introduction-to-selenium.html">1) Introduction</a>
I have used the xpath:
a.contains("1) Introduction")
But its not working. Can anyone help me?
The selector you're using is not xpath one, the correct xpath selector would be like this:
//a[contains(string(), "1) Introduction")]
To locate the element you can use either of the following Locator Strategies:
linkText:
1) Introduction
partialLinkText:
Introduction
cssSelector:
a[href^='/introduction-to-selenium']
xpath:
//a[starts-with(@href, '/introduction-to-selenium') and contains(., 'Introduction')]
selenium.common.exceptions.InvalidSelectorException with “span:contains('string')”
you can use contains also in xpath to identify the tag.
eg : //a[contains(text(),'Introduction')]
There should not be multiple "Introduction" in the page.