Comments (13)
Looks like capybara-webkit manually fires the events in JS.
We can do the same as a short-term solution, but in the longer term I'd like to submit a patch to PhantomJS to generate native keystrokes and let WebKit decide what events that should fire.
from poltergeist.
+1 on this. Lots of autocomplete tests will probably need this.
from poltergeist.
I personally wouldn't even delegate that task to PhantomJS.
I see PJS as the Browser and Poltergeist (or any capybara driver) as the user at the keyboard.
As a user, you type every key yourself and then blur out of the field to the next one or press a button. You don't "tell" the browser "paste that text here" and the Browser initializes keystrokes.
But that's just my 5 cent.
from poltergeist.
I had the same problem with using Poltergeist. But, might be I can fix it with Javascript and we can use it until Phantomjs fires these events by itself.
As far as I understood those things from Webkit driver must be brought to the Poltergeist? I want to try to contribute that.
from poltergeist.
@nestd yes, we can fire events with js until such time as we can get a patch in phantomjs to emulate proper "typing". Here's the code that currently sets input values - so you need to change that to closer resemble the capybara-webkit version.
Thanks
from poltergeist.
ok, I will do that
from poltergeist.
This was fixed #54
from poltergeist.
This issue seems to have reappeared. I found that using #fill_in
doesn't trigger autocomplete AJAX, but then connecting to the remote web inspector and firing a keydown()
on the input field in question caused it to trigger.
I've worked around it with a little helper:
def fill_in field, options
super
page.execute_script "$('label:contains(#{field})').siblings('input').keydown()"
end
from poltergeist.
I too have found the the same issue with fill_in
This does not trigger keydown events:
fill_in("q", with: "par")
While this does:
page.execute_script '$("#q").val("par").keydown()'
The output from debug looks like this:
{"name"=>"find", "args"=>[".//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')][(((./@id = 'q' or ./@name = 'q') or ./@placeholder = 'q') or ./@id = //label[contains(normalize-space(string(.)), 'q')]/@for)][not(./@disabled)] | .//label[contains(normalize-space(string(.)), 'q')]//.//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')][not(./@disabled)]"]}
{"response"=>{"page_id"=>2, "ids"=>[0]}}
{"name"=>"tag_name", "args"=>[2, 0]}
{"response"=>"INPUT"}
{"name"=>"attribute", "args"=>[2, 0, "type"]}
{"response"=>"text"}
{"name"=>"set", "args"=>[2, 0, "par"]}
{"response"=>true}
from poltergeist.
Thanks @benhoskings, the keydown()
worked for my autocomplete.
from poltergeist.
When erasing the content with:
fill_in 'input', with: ''
the key events are not raised. The problem is here, I think: https://github.com/jonleighton/poltergeist/pull/54/files#diff-893b71c0619c86f7b1058a9e9875af42R157
from poltergeist.
I am also experiencing this problem.
from poltergeist.
I'm also bumping into it ; sadly, this is a feature that would make sense to test what happens when emptying a search field for example.
(using poltergeist 1.10.0)
from poltergeist.
Related Issues (20)
- React event not triggered [help] HOT 2
- Capybara::Poltergeist::TimeoutError in some environments HOT 23
- ReferenceError: Can't find variable: Audio HOT 1
- React components not loading HOT 1
- Following jQuery line of code does not work in anything above v1.8.1 HOT 8
- Typo in keys method HOT 1
- Version of JS supported HOT 1
- Broken rails UJS loading when use arrow functions HOT 1
- Timeout occurs causing all following javascript tests to fail. HOT 3
- Capybara::Poltergeist::StatusFailError on 302 redirects with port numbers HOT 2
- Future of Poltergeist HOT 14
- Screenshot is not created HOT 1
- Authz request header missing HOT 5
- User agent does not persist across windows HOT 3
- Capybara::Poltergeist::TimeoutError when running CI tests HOT 7
- current_url returns empty string on about:blank HOT 3
- page.current_path always root HOT 2
- Possible make a method that check if JS Alert exist
- TypeError When dealing with link clicks via Capybara::Session HOT 2
- Capybara::Poltergeist::StatusFailError: failed to reach server (but manually I can connect perfectly) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poltergeist.