公共类Baseclass_libraries {
公共静态WebDriver驱动程序;公共静态fileutil flib = new fileutil(); 公共静态ExtentReports范围;公共静态ExtentTest scopeTest;
@BeforeSuite公共无效configBS()引发IOException {范围=新的ExtentReports(System.getProperty(“ user.dir”)+“ / test-output / ExtentReport.html”,true); scope.addSystemInfo(“主机名”,“本地主机”); scope.addSystemInfo(“用户名”,“自动化”); scope.addSystemInfo(“ Environment”,“ QA”); }
@BeforeClass公共无效configBc()引发IOException {System.out.println(“ ========午餐浏览器========); 属性pobj = flib.getpropertiesfileobject(); 字符串browsername = pobj.getProperty(“ BROWSER”); if(browsername.equals(“ chrome”)){System.setProperty(“ webdriver.chrome.driver”,“ ./Resourse/chromedriver.exe”); driver = new ChromeDriver(); } else if(browsername.equals(“ firefox”)){driver = new FirefoxDriver(); } else if(browsername.equals(“ IE”)){System.setProperty(“ webdriver.IE.driver”,“”); driver = new InternetExplorerDriver(); } driver.manage()。window()。maximize(); driver.manage()。timeouts()。implicitlyWait(20,TimeUnit.SECONDS);
Properties pobj=flib.getpropertiesfileobject();
String CMS_URL=pobj.getProperty("URL");
if(CMS_URL.equals("https")) {
driver.get(pobj.getProperty("URL"));
}
else if(CMS_URL.equals("https: ")) {
driver.get(pobj.getProperty("URL"));
}
LoginPage log=PageFactory.initElements(driver, LoginPage.class);
log.EnterUsername(pobj.getProperty("USERNAME").trim());
Thread.sleep(2000);
LoginPage pro=PageFactory.initElements(driver, LoginPage.class);
pro.clickOnProceed();
Thread.sleep(2000);
LoginPage pwd=PageFactory.initElements(driver, LoginPage.class);
pwd.EnterPassword(pobj.getProperty("PASSWORD"));
Thread.sleep(2000);
LoginPage sub=PageFactory.initElements(driver, LoginPage.class);
sub.clickOnSubmit();
} @AfterMethod public void configAm(ITestResult结果){System.out.println(“注销到Event2mobile”); LogoutPage lout = PageFactory.initElements(驱动程序,LogoutPage.class); lout.clickOnlogout(); } @AfterClass public void configAc(ITestResult结果){
if(result.getStatus()==ITestResult.FAILURE){
extentTest.log(LogStatus.FAIL, "TEST CASE FAILED IS "+result.getName()); //to add name in extent report
extentTest.log(LogStatus.FAIL, "TEST CASE FAILED IS "+result.getThrowable()); //to add error/exception in extent report
String screenshotPath = screenshot.getScreenshot(driver, result.getName());
extentTest.log(LogStatus.FAIL, extentTest.addScreenCapture(screenshotPath)); //to add screenshot in extent report
//extentTest.log(LogStatus.FAIL, extentTest.addScreencast(screenshotPath)); //to add screencast/video in extent report
}
else if(result.getStatus()==ITestResult.SKIP){
extentTest.log(LogStatus.SKIP, "Test Case SKIPPED IS " + result.getName());
}
else if(result.getStatus()==ITestResult.SUCCESS){
extentTest.log(LogStatus.PASS, "Test Case PASSED IS " + result.getName());
}
extent.endTest(extentTest); //ending test and ends the current test and prepare to create html report
driver.quit();
System.out.println("========close browser=========");
driver.close();
driver.quit();
} @AfterSuite public void configAS(){scope.flush(); scope.close(); }
} *
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。