I have a form which sends PATCH request with multiple submitting buttons
button_tag "Save", type: "submit", class: "btn btn-secondary", name: "commit", value: "save"
button_tag "Submit", type: "submit", class: "btn btn-secondary", name: "button", value: "submit"
there is controller action which check clicked button value.
def update
params[:commit].to_s.downcase == "save"
....
end
It returns true for development mode and using selenium driver, it breaks for a headless mode when I use poltergeist javascript_driver. In this case, the value is absent.
I have tested it using click_on "Save" command
What can be wrong with the headless browser that I can't get value eventually to compare which button was clicked?
Thanks so much in advance for advising.
I'm guessing the submission is AJAX driven using an actual PATCH request (as opposed to a POST request that passes a hidden _method
parameter set to 'PATCH').
Due to the version of QtWebkit PhantomJS (used by Poltergeist as its "browser") is built with it has an issue where the bodies of actual patch requests are always empty. Being based on QtWebkit (which was EOL'd) leaves PhantomJS approximately equivalent to a 6-7 year old browser and becoming less and less capable for testing modern JS driven applications. You're probably going to be better off just using Selenium with headless chrome for headless testing instead.