Not able to find web element in Span Tag

0 votes

Below is the tag I have in my html :

<span class="login-link">Log in</span>

And below is the code :

driver.findElement(By.cssSelector("#login > span")).click();

but I tried xPath, cssSelector and id, but it is not working.

Jun 21, 2018 in Selenium by Martin
• 4,320 points
5,393 views

1 answer to this question.

0 votes

Try using class selector also.

driver.findElement(By.cssSelector(".login-link")).click();

hash is used for referring id in css js. You must use dot(.) for directly referencing the element.

answered Jun 21, 2018 by Samarpit
• 5,910 points

Related Questions In Selenium

+1 vote
0 answers

Not able to find the element in a new form in the same webpage ,which popup after clicking a link

I am trying to locate an element ...READ MORE

Jun 27, 2020 in Selenium by Reshmi
• 130 points
1,814 views
+2 votes
0 answers

not able to get child element using parsed element in js function

I wrote below javascript code to fetch ...READ MORE

Dec 21, 2019 in Selenium by navikasingh
• 140 points
853 views
0 votes
1 answer

Not able to use “explicit wait” in my code

To wait until the entire data has ...READ MORE

answered Mar 28, 2018 in Selenium by nsv999
• 5,500 points
1,235 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,674 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,143 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,875 views
0 votes
1 answer

Not able to find element with Xpath

You are using wrong xpath expression. This ...READ MORE

answered Jul 4, 2018 in Selenium by Samarpit
• 5,910 points
4,814 views
0 votes
1 answer

Not able to call onclick datepicker function python selenium

To pass customized dates e.g. 2017/07/14. You have ...READ MORE

answered Jun 8, 2018 in Selenium by Samarpit
• 5,910 points
3,772 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP