网站上的多个元素

时间:2013-11-21 08:24:33

标签: selenium selenium-webdriver behat mink gherkin

我使用Behat与Mink和Selenium 2。 问题是我有两次元素......“设置”。 第一个元素是(例如)<a href="settings.php">Settings</a>,第二个元素是非可见菜单<a href="settings.php">Settings</a>中的快速链接。

如何在szenario中选择第二个“设置”元素?

当前示例:

Feature: Setting links
  Check the links

  Scenario: I check the links for settings
    Given I am logged in as "user":"name"
    Given The page is loaded
    # Now the problem... I have "Settings" twice and i would test both of them
    When I follow "Settings"
    And The page is loaded
    Then The parameter "sid" should match "[0-9]*"
    And I should see text matching "ID"
    And I should see text matching "Firstname"
    And I should see text matching "Surname"
    And I should see text matching "Street"
    And I should see text matching "Zip code"
    And I should see text matching "Country"

提前感谢您的任何提示! :)

1 个答案:

答案 0 :(得分:0)

例如。
如果您有以下html:

  

<div class="items ">

     
    
      

<a href="settings.php">Settings</a>

             

<a href="settings.php">Settings</a>

    
  

尝试使用以下步骤:

And I click on ".items a:second-child" element