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,240 points
2,318 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,170 points

Related Questions In Selenium

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,430 points
106 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,430 points
47 views
0 votes
1 answer

Source code to find element in Selenium-java

You are probably looking at the WebDriver interface alone. But, ...READ MORE

answered Apr 24, 2018 in Selenium by king_kenny
• 3,650 points
462 views
+3 votes
1 answer

Not able to run in chrome

There is a very silly mistake in ...READ MORE

answered May 15, 2018 in Selenium by king_kenny
• 3,650 points
482 views
0 votes
1 answer

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,430 points
1,182 views
0 votes
1 answer
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,170 points
1,268 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,170 points
1,025 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,170 points
1,050 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,170 points
1,324 views