Reputation: 73
The line of code for which i am writing the css regular expression is "<a href="https://mail.rediff.com/cgi-bin/login.cgi" title="Already a user? Sign in" class="signin" xpath="1">Sign in</a>"
The css regular expression which i wrote is -> "driver.findElement(By.cssSelector("//a[title*='Sign in']")).click();"
The syntax that i used was "//tagName[attribute*='value']"
Additional information I was able to write the regular expression x path without error
"driver.findElement(By.xpath("//a[contains(@title,'Sign in')]")).click();"
Thanks in advance
Upvotes: 0
Views: 93
Reputation: 978
why are you writing a regular expression? when we work with web elements you need to inspect web elements and should work with locators like id, name, CSS selector, link text...etc
You just inspect and pick locators and use in your selenium
Upvotes: 0
Reputation: 39
the Syntax for CSS Selector using regular expression in selenium is
tagname[attribute* = 'value']
So change the locator as
a[title*='Sign in']
Upvotes: 1