poltergeist


send_keys support for Poltergeist?


I want to switch from Selenium to Poltergeist but I need to simulate a barcode scanner that looks like keyboard entry to the <body> tag. I use this code with Selenium:
native.send_keys(send_key)
Is there a way with Poltergeist to send a string of keys to an arbitrary element (ie, not an input)?
Poltergeist now has send_keys support:
element = find('input#id')
# send a simple string
element.native.send_key('String')
# send a series of keystrokes
element.native.send_keys('H', 'elo', :Left, 'l') # => 'Hello'
# symbol for special keys
element.native.send_key(:Enter) # triggers Enter key
Since PhantomJS 1.7 (released 2012-09-22), you can send keyboard events to the headless browser using page.sendEvent.
The documentation includes an example simulating shift-A:
page.sendEvent('keypress', page.event.key.A,
null, null, 0x02000000 | 0x08000000 );
How exactly that input is handled by the page (i.e. what's targeted) will depend on the state of the page, such as where the focus is.
No, there is no way to do this at present. PhantomJS does provide an API for this, so it could be added in the future, but it's not currently supported.
I'd suggest trying to generate the DOM keyboard events in Javascript. Or just keep those specs using Selenium and use Poltergeist for the rest.
Starting from version 1.5.0, poltergeist supports basic send_keys.
https://github.com/jonleighton/poltergeist/blob/master/CHANGELOG.md#150

Related Links

How can I use “includeJs” function of phantomjs with poltergeist?
Poltergeist ruby gem fails to process `:shift` modifier in `send_keys`
Using Poltergiest to give user of app a screenshot of their page
Poltergeist 1.9.0 w/Ruby 1.9.3
Post via Capybara and Poltergiest for API testing
Poltergeist current_url command is returning page_info hash instead of a URL
How does one test the content of confirm dialogs using poltergeist?
Using Poltergeist, Phantom JS instances are not exiting during every rspec run
Render page element with padding in Poltergeist
Can I monkey patch the phantomjs browser api with execute_script?
send_keys support for Poltergeist?

Categories

HOME
date
blogger
gerrit
cookies
image-processing
plone
onedrive
syntax
spring-cloud-stream
sql-server-2016
callback
esper
python-unittest
kibana-4
here-api
offline
correlation
zend-framework3
workload-scheduler
ghc
graphlab
openrefine
evopdf
dbext
amazonsellercentral
telerik-reporting
claims-based-identity
firebase-crash-reporting
entitlements
procdump
madlib
noraui
catch-all
pim
phpfreechat
openoffice.org
accelerate-framework
force-layout
overriding
overlap
adobe-premiere
serve
libvpx
sharefile
ansible-playbook
opshub
tasker
grid.mvc
dynamic-reports
elmah
janrain
parentheses
ionicons
directory-structure
crypt
windows-mobile-6.5
root-framework
jquery-filter
captivenetwork
ptrace
wapiti
jfugue
iad
jmeter-maven-plugin
django-unittest
feedback
kcachegrind
sankey-diagram
inmobi
system.reflection
website-monitoring
gadt
angularjs-ng-click
android-imagebutton
rdtsc
client-side-templating
java-metro-framework
googlemock
wp-query
expected-exception
uv-mapping
multiprocessor
web2py-modules
jplaton
html4
assembly-loading
heartbeat
cinema-4d
disclosure
inotifycollectionchanged
dmx512
suppress
virtual-functions
aquaticprime
zune
uiq3

Resources

Encrypt Message