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,950 points
645 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
2 answers

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

driver.findElement(By.linkText("link")).click(); READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
589 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 22, 2019 in Selenium by Abha
• 28,100 points
248 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,500 points
7,368 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
7,023 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
4,703 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 3, 2020 in Selenium by Sri
• 3,190 points
5,841 views
0 votes
2 answers
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP