How can ID used as a locator to enter an email-id in gmail?

+4 votes
I have started my project on automating the process of login in Gmail and am new to selenium. Can someone help me on as how to locate the Username text box using ID?
Dec 18, 2018 in Selenium by Anjali
• 2,930 points
58 views

1 answer to this question.

+4 votes
Best answer

You can use the id field of the gmail to enter your email id:

See the screenshot attached:

Here the id is mentioned as   "identifierId" you can use that to find the element. Here is the code that I used to do this :

WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.gmail.com");
WebElement id = driver.findElement(By.id("identifierId"));
id.sendKeys("youremailid");
WebElement button = driver.findElement(By.className("CwaK9"));
button.click();

Hope this helps.

answered Dec 18, 2018 by Nabarupa

selected Dec 18, 2018 by Omkar

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to use link as a locator to find element in selenium?

Hello @Jino, its amazing to explore ways ...READ MORE

answered Dec 21, 2018 in Selenium by Nabarupa
110 views
0 votes
1 answer

How ID and Class can be used as a CSS Selector?

Hey Bruce, to identify a web element ...READ MORE

answered Jun 21 in Selenium by Abha
• 27,180 points
54 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,110 points
989 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
1,141 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
886 views
0 votes
2 answers