如何在挤压步骤之间共享数据

时间:2017-07-28 22:31:43

标签: python qt squish

我的功能文件在不同页面上具有相同的步骤。

Feature: Wizard

    Install wizard.

    Scenario: 1. Installing application.  
        Given App launch
        When Next button selected
        Then page1 is displayed
        When Next button selected
        Then page2 is displayed
        When Next button selected
        Then page3 is displayed
        When Next button selected

如何将当前页面传递给选择下一步按钮功能

2 个答案:

答案 0 :(得分:0)

如图here所示,您可以使用hash = { :key1 => value1, :key3 => value3, ... }.merge(condition ? {:key2 => value2} : {}) 步骤定义:

context

答案 1 :(得分:0)

Squish文档建议将“context”的使用限制为userData键。我相信这是因为一些较新的版本将信息发布到上下文对象(context.text是步骤标题等)。

因此,在OnScenarioStart钩子中,您可以设置上下文对象...

@OnScenarioStart
def hook(context):
    context.userData = {}

与此处的其他答案类似,您的步骤将如下所示..

@Given("App launch")
def step(context):
    # assuming page variable has your page content
    context.userData['page'] = page

@When("Next button selected")
def step(context):
    page = context.userData['page']
相关问题