-
Notifications
You must be signed in to change notification settings - Fork 81
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
Focus test not working in PhantomJS #48
Comments
Did you attach the elements to the DOM? Visibility tests won't work in-memory, the elements must be attached to the document. |
Closing this since lack of response. |
yes - they were attatched via jquery fixture in jasmine On Thu, Apr 5, 2012 at 2:28 AM, Michael Kessler
Modern Yoga vs Traditional Yoga |
I can confirm this bug, here's a PhantomJS script to reproduce: page = require('webpage').create()
page.onConsoleMessage = (msg) -> console.log msg
page.open 'http://www.google.com/', (status) ->
console.log 'Google loaded'
page.includeJs 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', ->
console.log 'jQuery injected'
page.evaluate ->
console.log "Is search focused? #{ $('input[name=q]').is ':focus' }"
$('input[name=q]').focus()
console.log "Is search focused? #{ $('input[name=q]').is ':focus' }"
phantom.exit() |
I has already been reported to the PhantomJS issue tracker, see Issue 427 and vote for it! |
thank you fro your help! On Thu, Apr 5, 2012 at 1:13 PM, Michael Kessler
Modern Yoga vs Traditional Yoga |
This issue is still present in PhantomJS 1.6.0. As workaround you can check the active document element: $('input[name=q]').get(0) == document.activeElement so you can write your own matcher in beforeEach ->
@addMatchers {
toBeFocused: -> @actual.get(0) is @actual.get(0).ownerDocument.activeElement
} |
@netzpirat thanks for the workaround |
Has anyone tried any of the newer versions of phantomjs? 1.9.0 seems to fix a lot of problems for me. |
No, I haven't tried it yet. |
I just tried this. Doesn't work unfortunately. Will be checking the activeElement property workaround for now. |
+1 ... currently requires mocking around |
I confirm, not working (thru Codeception stuff). |
Thanks for the reports. I'm not sure we'll be able to fix this in guard-jasmine since it seems like a phantomjs issue. I'll investigate it further and see if we can figure out a workaround, but I don't see any way we can do so at the moment. |
I'm running latest version of Grunt, Grunt Jasmine, jQuery and this is still an issue. However the document.activeElement shared by @netzpirat makes the trick. expect(defaultView.$('.some').get(0)).toBe(document.activeElement); |
Passed several years. The issue wasn't gone. |
I have keydown tests that seem to work fine in the browser with jasminerice
I am trying to get guard-jasmine working.
I need some assistance.
here is one of the tests that works in firefox and safari via jasmine rice and fails in phantomjs
The text was updated successfully, but these errors were encountered: