0

我有一个包含两种情况的功能文件:一种用于登录网站,另一种用于在登录页面上执行一些操作。如果我只用一个场景安排功能文件,它工作正常,尤其是在下面给出的第一个功能文件中突出显示的行。但是如果将同一个特性文件安排成有两个场景,就会出现网络定位器问题,即使在页面对象代码中,我给出了相同的代码行来定位网络元素。

第一个场景(使用大纲)只是登录网站。没有存储任何对象,或任何东西。

第二种情况是尝试验证页面上的一些数据,例如是否填充了带有用户 ID 和日期的行。

问题在于我在其中引入了第二个场景关键字的第二个功能文件,因为它完全是另一个单独的场景。

注意:-用于在两个地方定位 web 元素的代码(作为单独的项目维护)是相同的

请帮我找出问题所在。快把我逼疯了。

#########------此功能文件运行良好.-----
Feature: Data Extract List Page

    In order to test DataHub UI, 

     I want to specify the features of Extract History Page



  **Scenario Outline:** Navigate to Extract History page from the List page 

    Given the User opens the PRAMA Datahub website

     When the User types in userId "<uId>" and pacman passcode " 
      <pacman_passcode>"

      And the User clicks on submit button

     Then the User lands on page "<title>"  



     When status column-cell has status "Ready" value

     And last run column-cell has userid and date populated (NOTE:working 
     fine)

     And the User clicks on last run column cell of first extract record

      Then the User is navigated to the Execution History 
       "execution_history" page



     When the execution history page shows "completed" status

     And the User clicks on extract record header

     Then verify number of records greater than zero

     And file name is a valid string



    Examples: 

      | uId | pacman_passcode .  | title   | 

      | xxx | kT7&)cP^jhK&xze    | Datahub |  

###---此功能文件找不到网页元素(登录后的第一个)-#

**Feature:** Data Extract List Page

      In order to test DataHub UI, 

  I want to specify the features of Extract History Page



**Scenario:** User logs in to prama datahub website 

   Given the User opens the PRAMA Datahub website

   When the User types in userId "xxxxx" and pacman passcode 
    "kT7&)cP^jhK&"

    And the User clicks submit button

   Then the User lands on page "Datahub"



 **Scenario:**Navigate to Extract History page from the Extract List page

     Given User logs in to prama datahub website

     When status column-cell has status "Ready" value

     And last run column-cell has userid and date populated(NOTE: throwing 
    web element locator exception)

     And the User clicks on last run column cell of first extract record

    Then the User is navigated to the Execution History 
    "execution_history" page

更新: 只是为了好玩,当我注释掉可疑的“场景”关键字和伴随的@Given 步骤时,实际上并没有做任何新的事情,找到了网络定位器,没有问题!这里有什么好玩的?第一次登录场景中没有存储任何数据,什么也没有。只需登录,要求提供网络定位器。


**Feature:** Data Extract List Page

    In order to test DataHub UI, 

    I want to specify the features of Extract History Page



**Scenario:** User logs in to prama datahub website 

    Given the User opens the PRAMA Datahub website

When the User types in userId "pnutala" and pacman passcode "98hgdPwYxze"

  And the User clicks submit button

Then the User lands on page "Datahub"



 **#Scenario:Navigate to Extract History page from the Extract List page**

   **#Given User logs in to prama datahub website**

      When status column-cell has status "Ready" value

      And last run column-cell has userid and date populated

      And the User clicks on last run column cell of first extract record

      Then the User is navigated to the Execution History 
      "execution_history" page



      When the execution history page shows "completed" status

      And the User clicks on extract record header

      Then verify number of records greater than zero

      And file name is a valid string
4

1 回答 1

1

这个问题想通了。问题是由于没有意识到 Cucumber 将每个场景都视为全新的浏览器会话*

(对我来说感觉很奇怪,因为一个具有多个场景的功能必须是关于测试一个单独的故事。那你为什么需要一次又一次地销毁并重新启动并重新登录到浏览器呢?

*)。但是从 Serenity 开始,我有一个配置可以让浏览器会话在功能的整个生命周期内保持活动状态(serenity.restart.browser.for.each=feature)。现在调整每个场景的初始打开条件后,一切正常。——</p>

于 2019-03-18T14:48:49.397 回答