package demoActitime;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
public class LoginActitime {
private String UN;
private String Pass;
private WebElement username;
private WebElement password;
private WebDriver driver = new FirefoxDriver();
private String Url = "http://ift.tt/1M5mOrB";
private String Urlvalid = "http://ift.tt/1HpuG2V";
//
// @BeforeSuite
// public void Initialize()
// {
//
// }
@AfterMethod
public void findElements()
{
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
driver.get(Url);
String xpathUsername = "//input[@id='username']";
String xpathPassword = "//input[@type='password']";
String xpathLogin = "//a[@id='loginButton']/div";
driver.findElement(By.xpath(xpathUsername)).clear();
driver.findElement(By.xpath(xpathPassword)).clear();
driver.findElement(By.xpath(xpathUsername)).sendKeys(UN);
driver.findElement(By.xpath(xpathPassword)).sendKeys(Pass);
driver.findElement(By.xpath(xpathLogin)).click();
String currentUrl = driver.getCurrentUrl();
if(currentUrl.equals(Urlvalid))
{
System.out.println("Login Successfull");
}
else
{
System.out.println("Login Denied");
// driver.close();
}
}
@Test(priority = 0)
public void LoginValidUNInvalidPass()
{
this.UN="admin";
this.Pass="basheer";
System.out.println("LoginValidUNInvalidPass"); }
@Test()
public void LoginValidUNValidPass()
{
this.UN="admin";
this.Pass="manager";
System.out.println("LoginValidUNValidPass");
}
@Test
public void LoginInValidUNInvalidPass()
{
this.UN="basheer";
this.Pass="basheer";
System.out.println("LoginInValidUNInvalidPass");
}
@Test
public void LoginInValidUNValidPass()
{
this.UN="basheer";
this.Pass="manager";
System.out.println("LoginInValidUNValidPass");
}
}
The above code is to check login functionality of a website, where in the @Test method is not waiting web driver to return the current URL of the browser, the eclipse shows the test execution is completed.
Aucun commentaire:
Enregistrer un commentaire