小编And*_*lov的帖子

如何在JMeter中设置通常通过Javascript设置的cookie?

我正在测试一个Web应用程序.
在主页面的导航菜单中,单击节点时,将调用javascript函数.我查找了这个函数,页面将document.cookie="current_moduleId=xxxx;path=/"在重定向到目标页面之前设置.

那么如何在JMeter中为每个请求设置cookie?

javascript cookies jmeter

4
推荐指数
1
解决办法
8788
查看次数

capybara 2.0+中的嵌套功能

我想做这样的事情:

feature "sign-up" do
  before {visit signup_path}
  let(:submit) {"Create my account"}

  feature "with invalid information" do
    scenario "should not create a user" do
      expect {click_button submit}.not_to change(User, :count)
    end
  end

  feature "with valid information" do
    scenario "should create a user" do
      fill_in "Name",         with: "test name"
      fill_in "Email",        with: "test@test.com"
      fill_in "Password",     with: "password"
      fill_in "Confirmation", with: "password"
      expect {click_button submit}.to change(User, :count).by(1)
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

但是当我运行rspec时,我得到了

in `block in <top (required)>': undefined method `feature' for #<Class:0x000000039e0018> (NoMethodError)
Run Code Online (Sandbox Code Playgroud)

如果我改变它看起来像这样工作:

  feature …
Run Code Online (Sandbox Code Playgroud)

rspec capybara rspec-rails ruby-on-rails-3

4
推荐指数
1
解决办法
2942
查看次数

在Capybara表的复杂断言

我的应用中有一张桌子.

在此输入图像描述

使用Capybara和Cucumber,我如何断言值4.5和1.1只发生在Mike的行中?
在Capybara有这样的主张吗?

谢谢!

cucumber capybara

3
推荐指数
1
解决办法
1232
查看次数

如何从下拉列表中选择第一个元素.回报率/水豚/硒

所以这段代码工作得很好,直到我最近更新了我的selenium webdriver:

When /^I search for (.*)$/ do |term|
    term = " " if term == "blank"
    step "I fill in search with #{term}"
    within(".navbar-search") do
        page.find(:css, "li:first").click
    end
end
Run Code Online (Sandbox Code Playgroud)

我更新了,现在我收到以下错误:

 An invalid or illegal string was specified (Selenium::WebDriver::Error::UnknownError)
  ./features/step_definitions/search_steps.rb:5:in `block (2 levels) in <top (required)>'
  ./features/step_definitions/search_steps.rb:4:in `/^I search for (.*)$/'
  features/search_friend.feature:13:in `When I search for <term>'
Run Code Online (Sandbox Code Playgroud)

这是黄瓜功能:

@javascript
Scenario Outline: The search bar
    Given I login
    And I have a contact named ABC
    And I have a contact named …
Run Code Online (Sandbox Code Playgroud)

selenium ruby-on-rails cucumber capybara

3
推荐指数
1
解决办法
6472
查看次数

如何在链接中放置图像?

我正在尝试一些非常简单的东西,在我想要的文本和图像链接中.

= link_to 'NVidia Graphics', inventory_url, class: 'lato' do
  = image_tag 'list-highlighter.png'
Run Code Online (Sandbox Code Playgroud)

我希望输出类似于:

<a href="/inventory">
  NVidia Graphics
  <img src="list-highlighter.png" />
</a>
Run Code Online (Sandbox Code Playgroud)

如何使用Slim实现这一目标?我当前的代码导致网站崩溃.

用于" http://foobar.com/inventory "的未定义方法`stringify_keys' :String

ruby-on-rails image hyperlink slim-lang

3
推荐指数
1
解决办法
2233
查看次数

如何使用slim语法转义HTML内容中的方括号?

我需要使用slim语法打印以下内容:

tr 
  td "[Send] Value"
Run Code Online (Sandbox Code Playgroud)

要么

tr 
  td [Send] Value
Run Code Online (Sandbox Code Playgroud)

所以方括号是不可见的(所以解释得有些不同):我只得到 Value

怎么逃避--> [Send] <--

更新:

一些解决方法:

tr
  th = "[Send] Value"
Run Code Online (Sandbox Code Playgroud)

但我希望有一种更" 干净 "的方式来逃避方括号,而不是使用ruby解释器来逃避它们

html haml templates ruby-on-rails slim-lang

3
推荐指数
1
解决办法
2201
查看次数

为什么 Struts 2 没有提供更简单的方法来检索请求参数?

我将应用程序从 servlet 重写为 Struts 2。

以前为了获取参数值,我可以写:

request.getParameter("name");
Run Code Online (Sandbox Code Playgroud)

现在我应该这样做:

public class MyAction implements ParameterAware {
  private Map<String, String[]> parameters;

  @Override
  public void setParameters(Map<String, String[]> parameters) {
    this.parameters = parameters;
  }

  public String getParameterValue(String name){
    return parameters.get(name)[0];
  }

  // get this parameter
Run Code Online (Sandbox Code Playgroud)

当我使用 servlet 时,这要容易得多!

为了使代码干燥,我可以创建扩展 ActionSupport 的类 CustomActionSupport 并将此代码放在那里。但是为什么 Struts 不为我做呢?我怎样才能让我的生活更轻松?

我使用 ParameterAware 作为文档说这是一种首选方式

java servlets struts2

2
推荐指数
1
解决办法
1412
查看次数

在 slim 模板中渲染部分咖啡

这就是我所做的,在开发中工作,在生产中失败。

javascript:
  #{ raw render 'my_partial.js' }
Run Code Online (Sandbox Code Playgroud)

我的部分叫做my_partial.js.coffee.

这也适用于开发:

javascript:
  #{ raw render 'my_partial.js', handlers: [:coffee]}
Run Code Online (Sandbox Code Playgroud)

还有其他方法吗,比如:

coffee:
  #{ render 'my_partial' }
Run Code Online (Sandbox Code Playgroud)

我的意思是,在纤薄的模板中包含咖啡部分的最短形式是什么?以及为什么第一种方法在生产中失败,说:

ActionView::Template::Error (Missing partial my_partial 
with {:locale=>[:en], :formats=>[:js], :handlers=>[:erb, :builder, :slim]}
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails coffeescript slim-lang

2
推荐指数
1
解决办法
2802
查看次数

无法让Cucumber/Capybara找到单选按钮

我无法让Cucumber"选择"一个单选按钮,并希望有人可以给我一个健全检查.没有引用大量的HTML垃圾,这里是相关部分(我从print.html收集).它位于由按钮激活的模态div中.我可以"点击"那个按钮并看到模态窗口出现(我在Selenium中将其作为@javascript场景运行).

<div class="modal-body pagination-centered">
    <img src="/assets/payment.png" alt="Payment" />
    <form novalidate="novalidate" method="post" id="edit_cart_1" class="simple_form edit_cart" action="/carts/complete" accept-charset="UTF-8">
        <div style="margin:0;padding:0;display:inline">
            <input type="hidden" value="?" name="utf8" />
            <input type="hidden" value="put" name="_method" />
        </div>
        <div class="control-group hidden cart_property_id">
            <div class="controls">
                <input type="hidden" name="cart[property_id]" id="cart_property_id" class="hidden" />
            </div>
        </div>
        <div id="payment_fat_buttons" class="fat-buttons">
            <div class="vertical-button-wrapper">
                <input type="radio" value="cash" name="cart[payment_type]" id="cart_payment_type_cash_pay" data-property-id="1" />
                <label for="cart_payment_type_cash_pay">Cash</label>
            </div>
            <div class="vertical-button-wrapper">
                <input type="radio" value="credit" name="cart[payment_type]" id="cart_payment_type_credit_pay" data-property-id="1" />
                <label for="cart_payment_type_credit_pay">Credit</label>
            </div>
        </div>
        <div style="display: none;" id="cart_room_number_area_pay">
            <div class="control-group string optional cart_room_number"> …
Run Code Online (Sandbox Code Playgroud)

cucumber capybara ruby-on-rails-3

2
推荐指数
1
解决办法
2685
查看次数

servlet 3.0导入包的注释

在Servlets 3.0中,我们必须导入注释包.所以我想知道什么是类和接口?

import javax.servlet.annotation.WebServlet; 
Run Code Online (Sandbox Code Playgroud)

这里的servlet,annotation和WebServlet是javax包中的类或接口是什么?

servlets servlet-3.0

1
推荐指数
1
解决办法
1799
查看次数

使用Bundler获取git文件时出错

的Gemfile:

source "http://rubygems.org"
gem "nokogiri", :git => "git://github.com/tenderlove/nokogiri.git"
Run Code Online (Sandbox Code Playgroud)

运行时bundle,会发生以下错误:

Fetching git://github.com/tenderlove/nokogiri.git
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.4/lib/bundler/source.rb:592:in ``': No such file or directory - git clone "git://github.com/tenderlove/nokogiri.git" "C:/Ruby193/lib/ruby/gems/1.9.1/cache/bundler/git/nokogiri-d4bf05cb9e65f144f074351e5ebe3a0e44c00952" --bare --no-hardlinks (Errno::ENOENT)
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

它不仅可以与这颗宝石重现,还可以与其他宝石重现:黄瓜,水豚

我用的是Windows.

ruby git gem bundler

1
推荐指数
1
解决办法
1735
查看次数

访问 Report Portal API 时如何修复“未经授权”错误?

如何访问 API?

我越来越

{
  "error": "unauthorized",
  "error_description": "Full authentication is required to access this resource"
} 
Run Code Online (Sandbox Code Playgroud)

尝试使用basic身份验证类型时。

reportportal

1
推荐指数
1
解决办法
1393
查看次数

为什么这个jQuery代码检查所有复选框不起作用?

HTML:

<table class="responsive" id="products">
    <a href="#" id="checkAllProducts">Do it</a>
    <input type="checkbox">
    <input type="checkbox">
    <input type="checkbox">
</table>
Run Code Online (Sandbox Code Playgroud)

JS:

$(document).ready(function(){
  $('#checkAllProducts').click(function(){
    var checkbox = $('#products input:checkbox');
    checkbox.attr('checked',!checkbox.attr('checked'));
  });
});?
Run Code Online (Sandbox Code Playgroud)

它可以在这里进行调试.

代码可以工作var checkbox = $('input:checkbox');.问题可能出在选择器中

单击链接后,此代码应检查所有复选框.但它不会这样做.为什么?

javascript jquery

0
推荐指数
1
解决办法
579
查看次数