Automate the login process of facebook login

+3 votes
I am trying to automate the login process of facebook. Such that it directly takes the user id and password and logs in the account. I am new to selenium so can someone help me doing this? Thank you in advance.
Dec 18, 2018 in Selenium by Anjali
• 2,950 points
14,559 views
@User, is the person supposed to enter the username password externally? i.e. user should input the username and password?

1 answer to this question.

+3 votes

Hey @user, you can simply use findelements and the locator ID to get this done. In facebook they have a locator ID for each of the textbox and the buttons. 

Here is the code I used to do this:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Handsonsel {
     public static void main(String[] args) throws InterruptedException
     {
          System.setProperty("webdriver.chrome.driver","Yourpath\\chromedriver.exe");
          WebDriver driver = new ChromeDriver();
          driver.manage().window().maximize();
          driver.get("https://www.facebook.com");
          driver.findElement(By.id("email")).sendKeys("yourusername@gmail.com");
          driver.findElement(By.id("pass")).sendKeys("password");
          Thread.sleep(5000);
          driver.findElement(By.id("u_0_2")).click(); 
          Thread.sleep(7000);
     }
}

Hope this helps.

answered Dec 18, 2018 by Nabarupa

Related Questions In Selenium

+1 vote
1 answer
0 votes
2 answers
+1 vote
1 answer

How can I automate the process of adding iPhone to cart in Flipkart using Selenium(java),Page Object Model and TestNG? Also validate if product is added and available in cart?

Hey check this https://www.edureka.co/community/47160/automate-purchase-adding-book-cart-flipkart-using-selenium? It deals with a similar ...READ MORE

answered Jan 13, 2020 in Selenium by Karan
• 19,610 points
7,851 views
0 votes
1 answer

What is the process of installing Selenium IDE?

Hello Tarang, follow these steps to install ...READ MORE

answered May 13, 2019 in Selenium by Avantika
427 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
12,714 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
8,608 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,910 points
6,681 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
7,551 views
+10 votes
17 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,360 points
194,146 views
+1 vote
2 answers

How to get the title of a webpage using Selenium Java?

Essentially, driver.getTitle(); function can be used to ...READ MORE

answered Dec 17, 2018 in Selenium by Vardhan
• 13,190 points
15,310 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP