Coder Social home page Coder Social logo

Comments (7)

jferris avatar jferris commented on August 16, 2024

I think we just need to manually trigger the event when a check box is checked. The place to do this would be spec/driver_spec.rb and src/capybara.js if you want to try your hand at a patch.

from capybara-webkit.

hgmnz avatar hgmnz commented on August 16, 2024

Aren't we already triggering the change event here?

from capybara-webkit.

alduro avatar alduro commented on August 16, 2024

It seems I have the same problem. Having these two lines in a @javascript tagged scenario:
...
And I select "BSAC" from "membership[to_party_id]"
And I select second option from "membership_membership_type_id"
...

The first select triggering the change event to make and Ajax call that populates the second dropdown but it never being populated so the second select failed.

When /^I select second option from "([^"])"$/ do |locator|
select(find(:xpath, "//
[@id='#{locator}']/option[2]").text, :from => "#{locator}")
end

coffescript that makes the Ajax call:

$ ->
$("#membership_to_party_id").change( () ->
$.getJSON(
'/membership_types'
, { org_id: @.value }
, (data) ->
$("select#membership_membership_type_id option").remove();
row = "<option value="" + "" + "">" + "-- Select --" + ""
$(row).appendTo("select#membership_membership_type_id")
$.each(data, (index, elem) ->
row = "<option value="" + data[index].id + "">" + data[index].short_description + ""
$(row).appendTo("select#membership_membership_type_id")
)
)
)

from capybara-webkit.

halogenandtoast avatar halogenandtoast commented on August 16, 2024

I tested this out. The change event is triggering. @alduro I'm going to go on a limb here an say your issue is that your xpath expression is invalid. You've provided an axis, but no node. This seemed to work fine for me select(find(:xpath, "//select[@id='#{locator}']/option[2]").text, :from => "#{locator}")

from capybara-webkit.

FlaviuSim avatar FlaviuSim commented on August 16, 2024

I don't want to be out of line here, but I have a change event on a textfield that is not triggering when I fill_in some text in it. Is there another way to do it?

from capybara-webkit.

jferris avatar jferris commented on August 16, 2024

@closedbracket you can manually trigger events using trigger:

find_field("Some Label").set("some text").trigger("change")

capybara-webkit does fire change events for textfields, though. Can you also try your scenario using the Selenium driver? If you're still having issues, please open a new issue, as the original issue here was related to a bad xpath expression.

from capybara-webkit.

FlaviuSim avatar FlaviuSim commented on August 16, 2024

@jferris Thank you. It was my bad for not including js: true. Silly mistake.

from capybara-webkit.

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.