Giter Club home page Giter Club logo

Comments (13)

jonleighton avatar jonleighton commented on July 19, 2024

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.

atambo avatar atambo commented on July 19, 2024

+1 on this. Lots of autocomplete tests will probably need this.

from poltergeist.

mremolt avatar mremolt commented on July 19, 2024

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.

dnesteryuk avatar dnesteryuk commented on July 19, 2024

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.

jonleighton avatar jonleighton commented on July 19, 2024

@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.

dnesteryuk avatar dnesteryuk commented on July 19, 2024

ok, I will do that

from poltergeist.

jonleighton avatar jonleighton commented on July 19, 2024

This was fixed #54

from poltergeist.

benhoskings avatar benhoskings commented on July 19, 2024

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.

earnold avatar earnold commented on July 19, 2024

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.

jaredbeck avatar jaredbeck commented on July 19, 2024

Thanks @benhoskings, the keydown() worked for my autocomplete.

from poltergeist.

Valve avatar Valve commented on July 19, 2024

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.

jjb avatar jjb commented on July 19, 2024

I am also experiencing this problem.

from poltergeist.

Bastes avatar Bastes commented on July 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.