I am using web-watir to drive phantomjs. I am trying to submit a bunch of forms(POST) on the webpage. I have all the forms in a collection. When I click the submit button and browser.back()
, I get Selenium::WebDriver::Error::StaleElementReferenceError
. I tried using form.submit()
but same issue of going back and getting StaleElementReferenceError
. I tried to submit the form in another page (browser.execute_script( "window.open(page)" )
) but I don't think that will submit my form (if the form was a GET, that might have worked). I tried Net::HTTP.post_form()
which is separate from the phantomjs session (did not work, I need to be logged in).
I am out of ideas except find the elements all over each time I navigate back. I guess I could replace phantomjs with Chrome or Firefox. Tell me, is there a way to submit the form in a new page phantomJS?
Here is some code:
forms = browser.forms()
forms.each{ | form |
form.submit()
browser.back()
}