使用Appium驱动程序的Cucumber-jvm @after [英] Cucumber-jvm @after with Appium driver

查看:125
本文介绍了使用Appium驱动程序的Cucumber-jvm @after的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cucumber-jvm,并尝试实现全局@After方法,该方法在所有方案的执行完成后只能执行一次. @After方法应退出appium驱动程序.

I'm using cucumber-jvm , and trying to implement global @After method which should be executed only once after all scenario's execution was completed. The @After method should quit the appium driver.

当前@After挂钩是在每个运行方案之后执行的,这意味着应该从头开始创建驱动程序,但是我确实想重用它.

Currently @After hook being executed after each running scenario , and it means that the driver should be created each time from scratch , but I do want to reuse it.

任何帮助将不胜感激

推荐答案

您可以尝试使用

You can try using QAF which support Gherkin, where driver management is taken care by the framework. It is dedicated framework built upon TestNG for web, mobile web, mobile native, and webservices functional test automation.

使用QAF时,无需编写任何代码来安装/拆卸驱动程序.您可以根据需要通过testng xml配置文件和属性进行配置.您可以使用属性selenium.singletone指定行为.例如:

When using QAF you don't need to write any code to setup/teardown driver. You can configure as per your need through testng xml configuration file and properties. You can specify behavior by using property selenium.singletone. For example:

#will reuse driver session for close browser after all testcase configured under xml test node
selenium.singletone=true
#will teardown after each scenario/testcase
selenium.singletone=Method
#will reuse driver session for group
selenium.singletone=Groups

如果您正在并行运行,则可以在同一线程中运行的测试之间共享驱动程序会话.您可以通过执行配置实现所有组合.

If you are running in parrallel it will you can have driver session sharing between test running in same thread. All combinations you can achieve through execution configuration.

此外,您可以使用所有TestNG侦听器和注释.例如:

Moreover, you can use all TestNG listener and annotations. For example:

  • @BeforeMethod:在每个测试用例/场景之前调用
  • @BeforeSuite:在整个套件之前调用一次
  • @BeforeTest:为配置中的每个xml测试节点在每个xml测试节点之前调用一次
  • @BeforeGroup:为每个组开始执行组中的测试之前调用一次.
  • @AfterSuite:在整个套件后调用一次
  • @AfterTest:在整个xml测试节点之后调用一次
  • @AfterGroup:对每个组在组中进行所有测试后一次调用
  • @AfterMethod:在每个测试用例/场景之后调用
  • @BeforeMethod:Invokes Before each Testcase/Scenario
  • @BeforeSuite: Invokes once before entire suite
  • @BeforeTest: Invokes once before each xml test node for each xml test node in configuration
  • @BeforeGroup: Invokes once before starting execution of test in group for each group
  • @AfterSuite: Invokes once after entire suite
  • @AfterTest: Invokes once after entire xml test node
  • @AfterGroup:Invokes once after all test in group for each group
  • @AfterMethod:Invokes after each Testcase/Scenario

引用有QAF的小黄瓜

这篇关于使用Appium驱动程序的Cucumber-jvm @after的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆