1

我正在尝试编写测试以在我的移动网站上点击。但是,我无法找到有关如何单击嵌入的非链接元素的任何文档。这是我的 HTML:

form id="search-results-form" action="" method="post">
    <div>
        <ul id="see-more-search" class="see-more" style="display: block; height: auto;">
            <li>
                 <span>Color</span>
            </li>
            <li>
                 <span>Width</span>
            </li>
        </ul>
    </div>
 ...

这是我不完整的黄瓜测试:

When(/^touch "Color"$/) do
  within(:css, '#see-more-search') do
    #I want to be able to click the span with the text 'Color', but
    #don't know how to target it from this point
  end
end

有谁知道我将如何定位第一个li或“颜色”跨度?

4

1 回答 1

0

尝试使用 javascript:

page.driver.browser.execute_script %Q{ $('#see-more-search ul li:first').trigger("mouseenter").click(); }
于 2013-05-09T16:46:17.417 回答