I want to click on login button. Which attribute should I use to click on login button? I am new to selenium web driver. I am unable to find its link text, id, class name, name. I am not able to find its XPath or CSS selector. please advice me with the code. Image is here
Asked
Active
Viewed 288 times
-2
undetected Selenium
- 151,581
- 34
- 225
- 281
Abhishek
- 9
- 3
-
Please read why [a screenshot of code is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Paste the code and properly format it instead. – JeffC Jun 02 '18 at 02:56
-
See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Jun 02 '18 at 02:56
3 Answers
0
To click on element with text as LOGIN within the url https://phptravels.com/404/ you can use either of the Locator Strategies:
CssSelector:"a.login[href='http://phptravels.org']>span"XPath:"//a[@class='login' and @href='http://phptravels.org']/span[contains(.,'LOGIN')]" //or "//a[@class='login' and @href='http://phptravels.org']/span[contains(.,'Login')]"
undetected Selenium
- 151,581
- 34
- 225
- 281
0
You have multiple options, just avoid using xpath since its an overkill
li.user-login>a.login>span
or
a.login>span
or xpath
.//a[@class='login']/span[text()='Login']
nilesh
- 13,751
- 6
- 62
- 77
0
You can use either Xpath which is
.//*[@id='main-menu']/ul/li[8]/a
or CSS Selector which is
.login
Prany
- 1,948
- 2
- 11
- 26