I'm trying to pass username and passwords in different combinations (valid-valid, valid-invalid, invalid-valid, invalid-invalid) and have them assigned to String variables userName and password and have used a parameterized class.
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
@SuppressWarnings("deprecation")
@RunWith(Parameterized.class)
public class FunctionalTestCaseActiTimeParameterization {
Selenium selenium = new DefaultSelenium("localhost", 4444, "*firefox","http://localhost/login.do");
String userName;
String password;
public FunctionalTestCaseActiTimeParameterization(String userName, String password){
this.userName = userName;
this.password = password;
}
@Parameters
public static Object[][] getData(){
return new Object[][]{
{"admin","manager"},
{"admin","test"},
{"test","manager"},
{"test","test"}
};
}
@Before
public void openApplication(){
selenium.start();// start interaction with proxy server
selenium.open("/");// to open application
selenium.windowMaximize();// to maximize the window
selenium.windowFocus();// to focus on current window
}
@After
public void closeApplicaton() throws InterruptedException{
Thread.sleep(5000);
selenium.close();// close window
selenium.stop();// stop interaction with server
}
@Test
public void mainTestMethodLoginLogout() throws InterruptedException{
selenium.type("//input[@id='username']", userName);
selenium.type("//input[@type='password']", password);
Thread.sleep(3000);
}
}
and i didn't get any errors or warnings (I've used parameterized but not inside a function so getting a little confused about how to use it inside the type function, when run the code gives failure (no error).
I'd be glad if some one can point me in the right direction.