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,910 points
22 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+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

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

Getting Error in System.setProperty of ChromeDriver

System.setProperty("webdriver.chrome.driver", ...READ MORE

answered Jan 8 in Selenium by anonymous
1,272 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,030 points
51 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,130 points
410 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,130 points
40 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
132 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.