我无法使用Selenium Webdriver登录到Facebook帐户,并且用户名和密码也未显示在框中。我已经尝试从该站点进行Facebook登录测试用例,但未能获得预期的结果。 我错过了任何图书馆文件吗?有人请帮我找到解决方案。
我的代码试用如下:
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");
}
}
答案 0 :(得分:0)
尝试使用此
driver.findElement(By.id("loginbutton")).click();
代替
driver.findElement(By.id("u_0_r")).click();
PS:
我认为您正在输入: