当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - How can I test a button with a scroll down function on cucumber?

问题描述:

I'm writing cucumber tests for a website, and I've gotten completely stuck on this one. On the website's checkout procedure, there is a button that triggers a slidedown into the next part of the checkout procedure (on the same page). The button is defined in jQuery as follows:

 $("#next1").click(function(event){

$('#step1').slideUp(500);

$('#step1top').css('color','#036070');

$('#step1top').removeClass('active');

$('#step2top').css('color','#fff');

$('#step2').slideDown(500);

$('#step2top').addClass('active');

});

There are several others like this, and when you inspect element on the site, the HTML shown is as follows:

< img id="next1" src="/images/next.png" style="float:right;" >

I've tried to write steps that click inside elements. For example:

When /^I click "([^"]*)" inside element "([^"]*)"$/ do |button, element_name|

begin

evaluate_script("$('#{element_name}').trigger('mouseover')")

rescue Capybara::NotSupportedByDriverError

end

end

However, nothing that I've tried seems to work. Does anyone have any advice?

分享给朋友:
您可能感兴趣的文章:
随机阅读: