// This is my code //
package login;
import static org.testng.Assert.assertTrue; import org.testng.Assert; import org.testng.annotations.; import java.io.IOException; import com.thoughtworks.selenium.; import GenericLibrary.AdminUILib;
public class login {
public static Selenium seleniumObject;
@Test
public void TC_2() throws IOException
{
try {
System.out.print("TC_2 - Login data 2 : ");
seleniumObject = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.Google.com/”);
seleniumObject.start();
seleniumObject.windowMaximize();
seleniumObject.open(“http://192.168.2.104/login.jsp”);
seleniumObject.waitForPageToLoad(“50000”);
AdminUILib data = new AdminUILib();
data.testCaseId= “TC_2”;
data.workBookName = “TestData.xls”;
data.workSheetName = “login”;
data.fetchTestData();
assertTrue(seleniumObject.isElementPresent(“name=j_username”));
assertTrue(seleniumObject.isElementPresent(“name=j_password”));
seleniumObject.type(“name=j_username”, data.userName);
seleniumObject.type(“name=j_password”, data.userPassword);
System.out.println(data.userName + " , " + data.userPassword);
seleniumObject.click(“name”);
seleniumObject.waitForPageToLoad(“30000”);
if ((data.expectedResult).equals(seleniumObject.getText(“css=div:nth-of-type(1)”)))
{
System.out.println(“TC_2 passed”);
}
else
{
System.out.println(“TC_2 failed”);
Assert.fail("Login successful due to the username - " + data.userName + " and password - " + data.userPassword);
}
}
finally
{
System.out.println(“Exception”);
}
}
}