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,930 points

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("password"));
WebElement button1 = driver.findElement(By.className("CwaK9"));;

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

0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

Getting Error in System.setProperty of ChromeDriver

System.setProperty("", ...READ MORE

answered Jan 8 in Selenium by anonymous
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,090 points
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,130 points
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,130 points
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