Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined method `getByXPath' #55

Open
leifbladt opened this issue Feb 15, 2011 · 12 comments
Open

Undefined method `getByXPath' #55

leifbladt opened this issue Feb 15, 2011 · 12 comments

Comments

@leifbladt
Copy link

I switched from Selenium to Akephalos today. But one cucumber feature is not running.

undefined method `getByXPath' for # (NoMethodError) (DRb::DRbRemoteError)
(druby://127.0.0.1:49363) -e:1

I'm getting this error only in three scenarios inside one feature. The trigger is a "Then I should see 'something'". What happens before is a AJAX call which returns JavaScript, the client should execute. This works in other scenarios, but not in this one.

When I change the "I should see" to "Then show me the page", it also results in an error (undefined method 'getXml' this time).

[... JavaScript response from AJAX call]
ThreadSafeClientConnManager - Released connection is reusable.
ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://127.0.0.1:65432]][null]
ConnPoolByRoute - Pooling connection [HttpRoute[{}->http://127.0.0.1:65432]][null]; keep alive for -1 MILLISECONDS
IdleConnectionHandler - Adding connection at: 1297777311339
ConnPoolByRoute - Notifying no-one, there are no waiting threads
HtmlElement - Firing Event unload (Current Target: HTMLElement for HtmlHtml[]);
EncodingSniffer - Encoding found in HTTP headers: 'utf-8'.
WebWindowImpl - setEnclosedPage: com.gargoylesoftware.htmlunit.JavaScriptPage@759f6a57
WebWindowImpl - destroyChildren
JavaScriptJobManagerImpl - Waiting for all jobs to finish (will wait max 1000 millis).
JavaScriptJobManagerImpl - Finished waiting for all jobs to finish (final job count is 0).
JavaScriptJobManagerImpl - Waiting for all jobs that have execution time before 1000 to finish
JavaScriptJobManagerImpl - Finished waiting for all jobs that have target execution time earlier than 1297777312348, final job count is 0
@mattwynne
Copy link

I'm getting this too. As far as I'm aware, there's no javascript on the page at all. It seems like the thing that causes it in my case is that the preceding step submits a login form, which sends a redirect back to the browser. This scenario works with rack-test.

When I change the step to do a save_and_open_page instead, I get another undefined method error, this time for `asXml'.

@mattwynne
Copy link

Sorry if I'm hijacking this issue, but it looks like this is very relevant to my situation:
http://stackoverflow.com/questions/4824028/celerity-cannot-follow-a-devise-redirect-because-celerity-doesnt-send-an-accept

@aeseducation
Copy link

I get this error on local machines (OSX and Ubunto on Vagrant) and also on my hudson CI server. Sometimes the tests work fine and other times they fail.

@jnicklas
Copy link

jnicklas commented Mar 3, 2011

Matt: did you work out any way to set the accept header? Seems like Akephalos doesn't allow configuring this header, right?

@mattwynne
Copy link

@jnicklas, no I backed out of my whole akephalos experiment because of this issue.

@jnicklas
Copy link

jnicklas commented Mar 3, 2011

I found one workaround, actually. The problem for me is the redirect in Devise when authentication fails. Solution: don't let authentication fail ;) So by changing:

- visit(root_path)
+ visit(new_user_session_path)
fill_in 'Email', :with => 'Foo'

That way we're going to the sign in page directly, the redirect never happens, all is good!

@aeseducation
Copy link

FYI: I was able to fix the problem by changing the validate scripts setting. My application is Rails3 with prototype.js

Capybara.register_driver :akephalos do |app|
Capybara::Driver::Akephalos.new(app, :validate_scripts => false)
end

@leifbladt
Copy link
Author

Unfortunately, this doesn't work for me...

@jwhardcastle
Copy link

leifbladt: Did you ever solve this? We're having the same issue.

@leifbladt
Copy link
Author

No, unfortunately not. My workaround is to let these failing scenarios run with the selenium driver (which means they are not covered by our CI server...).

@caseydreier
Copy link

I'm also getting this issue while trying to use the "visit" command in Capybara within a Javascript-enabled Cucumber test in Akephalos. The Javascript being executed is attaching event handlers to clicks on page load using JQuery 1.6.

@asceth
Copy link
Contributor

asceth commented Jun 11, 2011

If you're getting UnexpectedPage as part of the error then try enabling debug output in htmlunit within akephalos. lib/akephalos/htmlunit.rb if using the gem or

Capybara.register_driver :akephalos do |app|
  Capybara::Driver::Akephalos.new(app, :htmlunit_log_level => "debug")
end

in my fork. This gives you more information to see why htmlunit is throwing an UnexpectedPage.

In my case, for a login form, I was not signing in successfully and being given a 401 which htmlunit loaded up as the UnexpectedPage. Turns out I needed to change DatabaseCleaner from transaction to truncation because transaction does not work properly with @javascript turned on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants