2

Can I call javascript on a page from a cucumber step using the capybara selenium driver? specifically i need to generate a change event when a form field is filled (doesnt seem like it does that by default). If so, could you provide an example?

I've tried googling but havent found an answer. thx.

1 Answer 1

3

You can use page.driver.browser.execute_script or page.driver.browser.evaluate_script (the latter will try to return a value)

Here is simple example of such kind of step:

When /^I hover and click on "([^\"]*)"$/ do |selector|`
  page.driver.browser.execute_script %Q{
    $("#{selector}").trigger("mouseenter").click();
  }
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.