desktoppr / wbench

It benchmarks websites, YO!
MIT License
1.34k stars 58 forks source link

Failing on nested classes in DIV #38

Open antosync opened 9 years ago

antosync commented 9 years ago

Mario/All.

Have a login page with submit button nested in DIVs. Button is defined like <div class="BS" id="ClientLogin_Ok">Login</div>.

wbench as called by few Ruby lines fails on /Library/Ruby/Gems/2.0.0/gems/capybara-2.4.4/lib/capybara/node/finders.rb:41:in block in find: Unable to find button "ClientLogin_Ok" (Capybara::ElementNotFound).

I had very few time to troubleshoot, so am not sure this is a wbench or capybara bug failing on nested classes in DIV or my fault.

Any idea?

mariovisic commented 9 years ago

Are you calling wbench from the command line or from ruby itself directly?

If you're using it through ruby you'll have to consult the capybara documentation to match the correct elements to perform the login, the ones on the readme are just an example. See here for more info: http://www.rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Actions

antosync commented 9 years ago

I am using this Ruby code:

require 'wbench' WBench::Benchmark.new('https://mysite', :browser => :chrome) benchmark.before_each do visit 'https://mysite/login' fill_in 'username', :with => 'myusername' fill_in 'password', :with => 'mypassword' click_button 'ClientLogin_Ok' end

results = benchmark.run(3) # => WBench::Results.

Ok, I'll look at page you suggest.

PS: Can't run wbench on login pages from command line, right?

mariovisic commented 9 years ago

Yes, so you'll need to change that section to match your form:

benchmark.before_each do
  visit 'https://mysite/login'
  fill_in 'username', :with => 'myusername'
  fill_in 'password', :with => 'mypassword'
  click_button 'ClientLogin_Ok'
end

You could test a page behind a login form, although you'd need to pass a cookie with a sessionID that is already logged in.