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

查看:29
本文介绍了带有 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.

任何帮助将不胜感激

推荐答案

您可以尝试使用 QAF 支持 Gherkin,其中驱动程序管理由框架负责.它是基于 TestNG 构建的专用框架,用于 Web、移动 Web、移动原生和 Web 服务功能测试自动化.

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:每组在group中测试后调用一次
  • @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

参考 Gherkin 与 QAF

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

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