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,330 points
3,592 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,890 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 26 in Selenium by Reshmi
• 130 points
1,030 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 20, 2019 in Selenium by navikasingh
• 140 points
85 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 27, 2018 in Selenium by nsv999
• 5,510 points
221 views
0 votes
1 answer

I need to find a web element using CSS

The element should be located with any ...READ MORE

answered Apr 12, 2018 in Selenium by nsv999
• 5,510 points
118 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,510 points
3,470 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31 in Selenium by Sri
• 2,970 points
4,483 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,890 points
2,562 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 2 in Selenium by Sri
• 2,970 points
2,798 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,890 points
2,547 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,890 points
1,993 views