testng 异常 截图

发表于:2018-11-02 11:11

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:岁月无言成追忆    来源:51testing采编

  3.Test1测试类
  package com.cmall.screenshot;
  import com.cmall.appium.DriverFactory;
  import com.cmall.appium.Helper;
  import com.cmall.appium.MultideviceManage;
  import com.cmall.http.LogUtil;
  import com.cmall.jdjr.pages.Modules.Integration.HomePage;
  import io.appium.java_client.MobileElement;
  import io.appium.java_client.android.AndroidDriver;
  import io.appium.java_client.pagefactory.AppiumFieldDecorator;
  import org.openqa.selenium.support.PageFactory;
  import org.testng.annotations.Listeners;
  import java.util.concurrent.TimeUnit;
  import org.testng.annotations.Test;
  @Listeners({ TestngListenerScreen.class })
  public class Test1 extends DriverBase
  {
  static AndroidDriver<MobileElement> mdriver = null;
  private LogUtil log = new LogUtil(Test.class);
  MultideviceManage m = new MultideviceManage();
  Helper helper;
  public Test1(){
  log.info("---------屏幕截图测试类---------------");
  }
  @Test
  public void test(){
  mdriver = DriverFactory.initDriver(4723,"TWGDU16B26001079");
  HomePage homePage = new HomePage();
  PageFactory.initElements(new AppiumFieldDecorator(mdriver, 20 , TimeUnit.SECONDS), homePage);
  // int a=1/0;//没预测到的--会截图
  try {
  Thread.sleep(2000);
  helper = new Helper(mdriver);
  helper.clickonElement(homePage.精选);
  // Assert.assertEquals(1,2);//会截图
  //throw new IllegalArgumentException("参数长度不是7位"); //不会截图
  int b=1/0;//能预测到被catch到的 不会截图
  } catch (Exception e) {
  e.printStackTrace();
  }
  }
  }
  4.配置xml文件
  <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
  <suite name="TestngListenerScreen" verbose="1" >
  <listeners>
  <listener class-name="com.cmall.screenshot.TestngListenerScreen"></listener>
  </listeners>
  <test name = "Test" >
  <classes>
  <class name="com.cmall.screenshot.ScreenTest"/>
  </classes>
  </test>
  </suite>

  5.把xml文件配置在pom.xml里

  上文内容不用于商业目的,如涉及知识产权问题,请权利人联系博为峰小编(021-64471599-8017),我们将立即处理。
22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号