尝试使用水豚,黄瓜和硒来点击简单模态窗口上的按钮

时间:2013-07-08 15:07:52

标签: ruby selenium cucumber capybara

我正在测试的网站提交了一个表单,一旦提交表单,就会显示一个简单的模态窗口,以便用一个关闭按钮来感谢用户。由于某种原因,我找不到点击该关闭按钮的方法。

以下是模态窗口的代码:

<div id="simplemodal-container" class="simplemodal-container" style="position: fixed; background-color: rgb(255, 255, 255); border: 3px solid rgb(102, 102, 102); padding: 30px; width: 380px; height: 270px; z-index: 1002; left: 409px; top: 63.5px;">
    <div tabindex="-1" class="simplemodal-wrap" style="height: 100%; outline: 0px; width: 100%; overflow: visible;">
        <div id="leadconfirm" class="overlaycontent simplemodal-data" style="">
            <span class="popupheader">Talk to a</span>
            <div class="indent">
                <p class="bold">Thank you! You'll be hearing from us very soon.</p>
            </div>
        <div class="buttonRow">
            <input id="registrationclose" class="simplemodal-close btn submitBut" type="submit" value="Close" name="close">
        </div>

我已经尝试了以下步骤定义,这是我之前尝试过的注释。

When /^I click on the xpath "([^\"]*)" button$/ do

find('button', :text => 'close')

#within("simplemodal-container")   { click_on button_name }

#find(:xpath,".//*[@id='registrationclose']").click_on button_id

# page.driver.browser.switch_to.alert.accept

end

When /^I click on the "([^"]*)" button$/ do |button_value|
click_button button_value
end

0 个答案:

没有答案