运行一个JavaScript黄瓜水豚它停止了
running a javascript cucumber capybara it halts
我有这种情况:
Scenario: If coming from savsale.com directly then the submenu items should open the right items.
Given the 'sales' page
When the user chooses 'women/accessories' from the navigation menu
而这一步:
When /^the user chooses '(.*?)'/(.*?)' from the navigation menu$/ do |menu,submenu|
begin
evaluate_script(%Q{console.debug('trying to show the menu:');})
command1 = "$('##{menu} ul').attr('style','display:block;visibility:visible');"
evaluate_script(%Q{console.debug("#{command1}");})
evaluate_script(command1)
evaluate_script(%Q{console.debug('first command done.');})
command2 = "$('##{menu}').addClass('sfHover');"
我也在使用硒网络驱动程序:
Capybara::Selenium::Driver.new(app, :browser => :firefox)
javascript 的执行没有达到以下代码:
evaluate_script(%Q{console.debug('first command done.');})
在火狐控制台中,显示如下:
$('#women ul').attr('style','display:block;visibility:visible');
但这不是:
first command done.
我认为它在 execute_script(command1) 处停止,然后它失败并出现超时异常......
When the user chooses 'women/accessories' from the navigation menu # features/step_definitions/steps.rb:193
Timeout::Error (Timeout::Error)
有人有好主意吗?
天哪,过了一会儿,我意识到我尝试的页面返回的对象上有一个execute_script并且它可以工作......天哪......所以所有的javascript现在都执行了...
When /^the user chooses '(.*?)'/(.*?)' from the navigation menu$/ do |menu,submenu|
begin
sleep 10.seconds #wait for the js to load the menus
page.execute_script(%Q{console.debug('trying to show the menu:');})
command2 = "$('##{menu}').addClass('sfHover');"
page.execute_script(command2)
command1 = "$('##{menu} ul').attr('style','display:block;visibility:visible');"
page.execute_script(command1)
command3 = "$('a[filter-category=#{menu}][filter-sub-category1=#{submenu}]')[0].click();"
page.execute_script(command3)
rescue Capybara::NotSupportedByDriverError
end
end
相关文章:
- 为什么不't Javascript对我的输入值进行了一些重新检查
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 将函数的上下文应用于javascript变量
- 使用php或javascript从facebook相册URL中删除多余的部分
- 正在添加'X'按钮,在文本字段旁边使用javascript
- 如何在JavaScript中将字符串转换为函数引用
- 模糊事件的Javascript测试
- Javascript更改图标
- 如何将HTML id分配给元素,以及如何将JavaScript应用于元素
- 运行一个JavaScript黄瓜水豚它停止了
- 像PHP一样使用json数组“水合”Javascript对象实例
- Angular/JavaScript自动水合实例
- 测试javascript点击功能水豚附文件图片上传
- 黄瓜水豚硒竞态条件与期望(all())
- 带javascript和工厂女孩的水豚
- Rails 3.1水豚javascript测试访问被拒绝
- Javascript水涟漪效应减慢帧率
- 如何获得javascript与黄瓜
- 从黄瓜步骤调用javascript
- 在JavaScript/html中水平镜像d3图