Monday 27 April 2015

Login to facebook with invalid login credentials and verify error message.

package WebdriverDemo2;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class FBInvalidCredentials {

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://fb.com");

String ExpectedRes = "Incorrect Email";

driver.findElement(By.id("email")).sendKeys("dcduhu");
driver.findElement(By.id("pass")).sendKeys("cdyghdyg");
driver.findElement(By.xpath("//input[@value='Log In']")).click();

String ActualRes = driver.findElement(By.xpath("//div[contains(text(),'Incorrect Email')]")).getText();

if(ExpectedRes.equals(ActualRes))
{
System.out.println("Text check complete--> PASS!");
}
else
System.out.println("Text check not complete--> FAIL!");

}

}

No comments:

Post a Comment