import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class DifferentMeterLogin
{
public WebDriver driver;
//public String baseUrl = "https://website.com/";
//private String username="1003852@us";
//private String password="password";
@DataProvider
public Object[][] testData()
{
Object data[][]=new Object[2][2];
data[0][0]="1003852@us";
data[0][1]="password";
data[1][0]="1003854@us";
data[1][1]="password";
return data;
}
@BeforeSuite
public void setUp()
{
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@AfterSuite
public void testDown()
{
driver.quit();
}
@AfterTest
public void logOff()
{
driver.navigate().to("https://website.com/Account/LogOff");
//driver.findElement(By.xpath("//*[@id='logoffstatus']")).click()
}
@Test(priority = 1,dataProvider = "testData")
public void loginConsumerPortal(String username, String password)
{
System.out.println("Logging in...");
driver.get("https://website.com/");
driver.findElement(By.id("id_username")).clear();
driver.findElement(By.id("id_username")).sendKeys(username);
driver.findElement(By.id("id_password")).clear();
driver.findElement(By.id("id_password")).sendKeys(password);
driver.findElement(By.tagName("button")).submit();
System.out.println("Submitted");
}
@Test(priority=2)
public void isLoginSuccessfull() throws InterruptedException
{
System.out.println("Checking if successfull login");
Assert.assertEquals("Dashboard", driver.findElement(By.xpath("//*[@id='ConsumerDashboard-cnt_int']/h4")).getText());
Thread.sleep(5000);
}
}
**--------------------------------------------------------------------------* *
I have different types of login credentials. I should be able to login with all types of id's and visit all menus. I am using only firefox and using TestNG data provider to provide data.
The problem is :
The test is using 1 browser, whereas it should have used multiple windows. Firefox handles sessions separately for all profiles i guess.
What I am thinking is there should be 2 windows of Firefox opened.
but that is not happening.
Thanks in Advance