Getting error while accessing the password field in gmail.

+4 votes
I am trying to create a auto login where the user inputs id and password and gets logged in in their account. I am able to access the id part but am unable to get the password. It is giving some error.

Can someone help me?
Dec 18, 2018 in Selenium by Anjali
• 2,950 points
117 views

1 answer to this question.

+3 votes

Hello @User, this was the error I was facing when I was playing with selenium. Most of the times we get this error because we are trying to use a common element's name such as class name. Id is always distinct for all the web elements. Try using ID all the time and when there is no ID use xpath. 

Here in gmail they have seperate class name for password know as 'password'. Here is the screenshot that I have shared.

You can simply use the name field here like this: 

WebElement password = driver.findElement(By.name("password"));
password.sendKeys("mypassword");
WebElement button1 = driver.findElement(By.className("CwaK9"));
button1.click();

Here we are first finding element by name i.e. password

then we are clicking on the submit button that button we are finding using ClassName here i.e. "CwaK9"

then we are clicking it. Remember to make the browser wait as you don't want the browser to close before you feed the information.

Hope this helps.

answered Dec 18, 2018 by Nabarupa

Related Questions In Selenium

+1 vote
1 answer
0 votes
1 answer

What is the actual conflict while performing click() on web element, and getting an error like element is not clickable at point(x,y)?

Hey @sastry, the error Element is not clickable ...READ MORE

answered Nov 27, 2019 in Selenium by Sirajul
• 58,130 points
1,292 views
0 votes
1 answer

Getting error while run the selenium scripts.How can i resolve this issue?

Tq. Yes, it worked for me. READ MORE

answered Jun 16 in Selenium by anonymous
397 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,520 points
3,783 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,766 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,742 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
3,109 views
0 votes
1 answer

Getting error while running a XML file in TestNG

Hello @Sradha, The synatx of using test is ...READ MORE

answered Dec 26, 2018 in Selenium by Rashmi
6,396 views