简体   繁体   English

在使用Cucumber实现的相同方案中,我们如何利用Selenium WebDriver和Appium?

[英]How can we make use of Selenium WebDriver and Appium in the same scenario implemented using Cucumber?

I have a situation where I need to perform some steps in the Website(Selenium) where I execute some steps to create some data and them it is pushed to mobile app. 我遇到一种情况,我需要在网站(硒)中执行一些步骤,在其中执行一些步骤以创建一些数据,然后将它们推送到移动应用程序中。 I want to work on it on the Mobile side(Appium) and take the flow ahead. 我想在移动端(Appium)上进行开发,并继续进行。 Once I complete the operations on mobile. 一旦完成手机上的操作。 I must validate the same on Web site again. 我必须再次在网站上验证相同的内容。 This all needs to be done in one scenario as I don't want my scenarios to be dependent on other scenario. 所有这些都需要在一个方案中完成,因为我不希望我的方案依赖于其他方案。 Basically the web flow will be present in every scenario I would be writing. 基本上,Web流将出现在我要编写的每个场景中。

Now when I am trying to do this using Background or @Before , Even my Appium object is instantiated and remains idle till the time WebDriver performs its steps. 现在,当我尝试使用Background或@Before进行此操作时,即使我的Appium对象也被实例化并保持空闲状态,直到WebDriver执行其步骤为止。 I want my AppiumDriver to be instantiated only after the execution of WebDriver Steps. 我希望仅在执行WebDriver步骤之后才能实例化AppiumDriver I appreciate your help. 我感谢您的帮助。 TIA! TIA!

background once in a feature before any scenario on that feature. 功能中的任何背景之前,先在该功能中使用该背景。

before executes each time before any scenario. 在任何情况下每次执行之前。

As per your requirement it depends when you are initializing your AppiumDriver instance, It means if your initializing your appium driver in a gherkin statement then using before can work for you, use 根据您的要求,这取决于您何时初始化AppiumDriver实例,这意味着如果您在一个小黄瓜语句中初始化appium驱动程序,那么使用before可以为您工作,请使用

Tagged Hooks It is possible to define a hook so that it is only executed before or after scenarios that are tagged with a specified annotation, for example: 标记的挂钩可以定义挂钩,使其仅在使用指定注释标记的场景之前或之后执行,例如:

Feature: web text munger kata
  @web
  Scenario: It should process a sentence

Tag your scenario which required this before to run only for it, not for all 标记您的方案,此方案仅在此之前运行,而不是全部运行

Stepsdefination: 步骤定义:

@Before("@web")
public void beforeScenario() {
  // perform your webdriver code
}

For better understanding go through the below link: 为了更好地理解,请通过以下链接:

https://zsoltfabok.com/blog/2012/09/cucumber-jvm-hooks/ https://zsoltfabok.com/blog/2012/09/cucumber-jvm-hooks/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM