0

I'm unable to login into Facebook account by using Selenium webdriver and also the username & password is not displayed in the box. I've tried Facebook login test case from the site but failed to get the expected result. Did i miss any library files ? someone please help me to find a solution for this.

My code trial is as follows :

package testng2;
import  org.openqa.selenium.By;   
import org.openqa.selenium.WebDriver;    
import org.openqa.selenium.chrome.ChromeDriver;    

public class FacebookLogin {

    public static void main(String[] args) throws InterruptedException {

        String exePath = "E:\\sreeja\\testing\\selenium\\chromedriver.exe";
        System.setProperty("webdriver.chrome.driver", exePath);

        WebDriver driver = new ChromeDriver();

        driver.get("https://www.facebook.com");
        System.out.println("Successfully opened the website");
        driver.manage().window().maximize();
        driver.findElement(By.id("email")).sendKeys("Enter the USERNAME");
        driver.findElement(By.id("pass")).sendKeys("Enter the PASSWORD");
        driver.findElement(By.id("u_0_r")).click();
        System.out.println("Successfully logged in");
        Thread.sleep(3000);
        driver.findElement(By.id("userNavigationLabel")).click();
        Thread.sleep(2000);
        driver.findElement(By.partialLinkText("Log out")).click();
        System.out.println("Successfully logged out");

    }
}
NarendraR
  • 7,577
  • 10
  • 44
  • 82

1 Answers1

0

try using this

driver.findElement(By.id("loginbutton")).click();

instead of

driver.findElement(By.id("u_0_r")).click();

P.S :

I assume that you are entering :

  • your Facebook username inside the quotes instead of "Enter the USERNAME"
  • your Facebook password inside the quotes instead of "Enter the PASSWORD"