如何使用 Cucumber jvm 和 selenium webdriver 为功能文件中的每个场景提供唯一的序列号

how to give a unique serial number to each scenario in a feature file using cucumber jvm and selenium webdriver

由于场景太多,当出现故障或错误时,我很难跳转到有问题的场景。

有没有办法给每个场景一个唯一的编号,以便于映射并且也可以用于日志记录。

我正在将 selenium webdriver 与 Cucumber jvm 和 pageobjects 一起使用。

功能文件的示例:

    #1
    @regression @CPM_PI @visibility
    Scenario Outline: To check if CPMPI panel is visible
    Given Go to Nerd
    And set Team="CTM"
    And set Client="PQR"
    And set Broker="ABC"
    And select Product="CPM"
    And set Revenue"1000000"
    And set Revenue(CY)="500000"
    And tick Coverages="CPM/PI"
    And select Main Activity="<MainActivity>"
    Then check CPMPI visible


    #2
    @regression @CPM_PI @visibility
    Scenario: To check visiblity of all CPMPI panels
    Given Go to Nerd
    And set Team="CTM"
    And tick Cyber 
    Then check panel Cyber visible

您可以简单地 "tag" 您的场景名称,例如:

Scenario Outline: Scenario 1: To check if CPMPI panel is visible
Given Go to Nerd
And set Team="CTM"
And set Client="PQR"
And set Broker="ABC"
And select Product="CPM"
And set Revenue"1000000"
And set Revenue(CY)="500000"
And tick Coverages="CPM/PI"
And select Main Activity="<MainActivity>"
Then check CPMPI visible


#2
@regression @CPM_PI @visibility
Scenario: Scenario2: To check visiblity of all CPMPI panels
Given Go to Nerd
And set Team="CTM"
And tick Cyber 
Then check panel Cyber visible

养成为场景命名的习惯