How to upload a file in form tag in chrome headless? - google-chrome-headless

How I can submit a form by chrome headless using puppeteer or without it?
Just a form with input type="file".

Related

Can I stop dompdf page hard reload in laravel dompdf?

I have used dompdf in my laravel application and I'm calling the pdf generate function from the same form submit button and both are working fine. The only issue I'm facing right now is on my generated pdf file every hard refresh/reload, form data is submitting again to the database. Is there any possible way that i can prevent that reload or form submit?
I tried with this below Jquery but that completly prevent my form by clicking the button also. I just want that form not to submit again on pdf file reload.
$("#orderForm").submit(function(e) {
e.preventDefault();
});

Browser Rendered Page Appears Different When Scraped

opening this page https://www.barchart.com/futures/quotes/ESH20/options
in Nokogiri doesn't have the same elements as in the rendered page inside the browser.
How can I access the same source code as seen in the Browser DevTools from the scraper library?
this element in particular <div class="bc-datatable"...
is required an headless browser to get the right page code first?
That data is coming from a JSON endpoint:
So luckily no headless browser required this time.

Can watir-webdriver submit a form without opening a GUI browser like Chrome?

Can I set values for input fields and submit a form using watir-webdriver without opening a browser display?
If you install the headless gem (and its system dependencies) it should be easy to start the browser in headless scope:
Headless.ly do
# start your browser
end

How to submit a form in a new page with using ruby web-watir phantomjs

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()
}
If submitting each form brings you to another page, then it is expected that you get a StaleElementReferenceError for any previously saved elements. This is how Selenium-WebDriver was designed, so the problem will still exist if you switch to Chrome or Firefox.
Given that you are iterating through each form, it would be easy to locate each form by index:
browser.forms.length.times do |i|
browser.form(index: i).submit
browser.back
end
The above code took the same approach of directly submitting the form. However, if possible, the submit button should be clicked. Directly submitting the form may bypass important code that is tied to the action of clicking the submit button.

how to send mulitple image upload form data via ajax to node.js

i want to send form data to server side via jQueryajax . i am uploading multiple images .
when i press submit button, i should send images path via ajax to server(node.js)
but here i am using form so
how to do that ?
i have tried this one.but it is not working for multiple image upload
http://blog.w3villa.com/websites/uploading-filesimage-with-ajax-jquery-without-submitting-a-form/
thing which you need to take care is cross-browser compatibility and unfortunately Formdata in not supported in Internet Explorer.
I would suggest you to use Uploadify JQuery plugin. You can download it from http://www.uploadify.com/. You can use the flash version, I have tested it and it works fine with IE as well.
Best of Luck.

Resources