Sample Login Script using selenium webdriver using ATU reporting
ClassName:- TC001_login.java
@Listeners({
ATUReportsListener.class, ConfigurationListener.class, MethodListener.class })
public class TC001_Login {
Properties prop = new
Properties();
InputStream input = null;
WebDriver driver;
String desc,inputt, expResult,
actResult;
{
System.setProperty("atu.reporter.config", "C:\\Users\\Kalyan\\workspace\\testProject\\atu.properties");
}
@DataProvider(name =
"test")
public Object[][] createData1()
throws IOException {
Object[][]
object=new Object[2][2];
ArrayList<ArrayList<String>> data =
DataInputProvider.getSheet("Login","Sheet1");
for (int i =
0; i < data.size(); i++) {
object[i][0]=(Object)data.get(i).get(0);
object[i][1]=(Object)data.get(i).get(1);
}
return object;
}
@SuppressWarnings("deprecation")
@Test(dataProvider =
"test")
public void loginMhs(String n1,
String n2) throws IOException {
ArrayList<ArrayList<String>> data1 =
DataInputProvider.getSheet("Login","Sheet2");
// for (int i
= 1; i < data1.size(); i++) {
int i=0;
WrapperMethods wM = new WrapperMethods("MHS Login",0);
// launch the browser
wM.invokeApplication("firefox", " http://softwaretestingbin.blogspot.in/",data1.get(i).get(0),data1.get(i).get(1),
data1.get(i).get(2));
try {
input = new FileInputStream("C:\\Users\\Kalyan\\workspace\\testProject\\object.properties");
// load a properties file
prop.load(input);
i++;
// enter user name
wM.enterValueById(prop.getProperty("username"),
n1,data1.get(i).get(0),data1.get(i).get(1), data1.get(i).get(2));
i++;
// enter password
wM.enterValueByName(prop.getProperty("password"),n2,data1.get(i).get(0),data1.get(i).get(1),
data1.get(i).get(2));
i++;
// click login
wM.clickByCSS(prop.getProperty("loginSubmit"),data1.get(i).get(0),data1.get(i).get(1),
data1.get(i).get(2));
i++;
// click logout
wM.linkClickByText(prop.getProperty("logoff"),data1.get(i).get(0),data1.get(i).get(1),
data1.get(i).get(2));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
i++;
// close app
wM.closeApplication(data1.get(i).get(0),data1.get(i).get(1),
data1.get(i).get(2));
}
public static void
reportStep(String desc, String inputt, String status, String expResult, String
actResult) throws IOException {
//
ArrayList<ArrayList<String>> data1 =
DataInputProvider.getSheet("TestSteps","Sheet1");
if(status.toUpperCase().equals("SUCCESS"))
//ATUReports.add("Pass Step 1", LogAs.PASSED, new
CaptureScreen(ScreenshotOf.DESKTOP));
ATUReports.add(desc,inputt,expResult,actResult, LogAs.PASSED, new
CaptureScreen(ScreenshotOf.BROWSER_PAGE));
else
ATUReports.add(desc,inputt,expResult,actResult, LogAs.FAILED, new
CaptureScreen(ScreenshotOf.DESKTOP));
}
}
Hello
ReplyDeleteI'm new to automation. Can you please detail the content of atu.properties file.
Thanks
Tanmay
Sure DimeStore.. Let me know your doubts please.. So that i will clarify in depth..
ReplyDelete