Based off of this discussion: Watir Web driver to download file
Is there any other way similar to this to download a file using Watir without using something like RAutomation or AutoIT? The website I have to use is only formatted for IE and breaks when using other browsers.
Related
I am using google chrome headless for some crawling.
When crawler visit page with file like this: www.example.com/file.zip file is downloaded, I don't want to downloaded file. Is there any way how to disable download in start up flags? Or some other way?
Have a requirement to print html or html from vb6 application using only firefox as we have already for IE. So, need command to print using firefox.exe.
Something like this firefox.exe -print http://www.google.com which is not working. Is there anyway to do this? Thanks for your help.
There is no built-in support for a -print command line switch. See this document for the different command line switches supported for the Firefox browser. Support for such functionality would most probably have to be implemented through an extension.
If no extension exists that currently offers what your looking for, a Google search yielded this mozillaZine forum thread: "Printing to file from Commandline?" You could have a look at the discussion, or download and modify the referenced add-on from the source link.
Or else, you could always create your own application (probably not in VB6) by embedding the Gecko layout, but since the Mozilla killed the embedding API a while back, you'll have a lot of integration work to do (or else you could go with another layout engine like Webkit).
You can use the built in webbrowser control to print html via IE: http://www.vbforums.com/showthread.php?384076-Webbrowser-Control-Tip-and-Examples
If you must use firefox, there was a firefox active x control but I have not used it and dont know the status:
mozilla firefox activeX
or
http://www.iol.ie/~locka/mozilla/control.htm
or
https://bitbucket.org/geckofx
It also looks like there is a webkit floating around online (google it)
I would like to programatically instruct Firefox to visit a list of URLs (defined in a text file, for instance) and for each of them save the page to disk or print it.
I know Selenium provides a feature to capture a screenshot of the page, but I would like to know if it's possible to use browser's native saving and printing features.
If Selenium does not provide such features, would any other tool allow me to define a script to be executed by Firefox and achieve similar results?
It is possible to enable silent printing in firefox to print to the default printer, bypassing the print dialog.
The required firefox preference is print.always_print_silent, and can be setup with selenium like so:
import org.openqa.selenium.JavascriptExecutor;
/* ... */
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("print.always_print_silent", true);
WebDriver driver = new FirefoxDriver(profile);
Now simply navigate to a web page and call print using javascript:
driver.get("http://www.google.com");
((JavascriptExecutor)driver).executeScript("window.print();");
Additionally, couple this with a free PDF printer such as novaPDF to print without displaying the Save as dialog and automatically save a PDF to a predefined location.
If you are fine with png format, you can take full page screenshot.
import selenium.webdriver
import selenium.common
options = selenium.webdriver.firefox.options.Options()
# options.headless = True
with selenium.webdriver.Firefox(options=options) as driver:
driver.get('http://google.com')
time.sleep(2)
root=driver.find_element_by_tag_name('html')
root.screenshot('full page screenshot.png')
Normally you would do this using Sikuli API. The open source community (a.k.a. Mozilla foundation) is working on a project called Marionette that supposedly will enable you do do these things without using screenshot matching but it's still alpha and they are still working on it and Chrome and IE haven't signed onto it yet.
It should be noted that on native file downloads, you don't really need to test the browser functionality of the already well tested save-as dialog. What Selenium testers usually do is just download the file with Apache HttpUtils or something similar and just bypass the browser on the download step. Then you don't need to use the Save-As dialog and it will work cross-browser. Just use selenium to get the download URL and download it with Java code instead.
Maybe this can helps you...
https://stackoverflow.com/a/64987078/6003328
I made this using python...
Basically, I change the about:config settings for each print, adjusting the filename of the pdf to be created, and setting the printer as always_print_silent: true...
I'm using valums file_uploader.js to upload files & I wanted to upload all the type of files like images, audios, videos, etc. It is working very fine in firefox & chrome. In safari upload is working good except for multiple files. But in IE nothing is working.
There is one line input.files to fetch the file details. It is giving null or undefined in IE.
I tried all the versions of IE, 7-9. But no use.
How do I get the file properties in IE using javascript. I tried to use ajax-uploader, but I'm not getting how to use it.
I'm using ruby 1.9.2, rails 3.2.1 & jquery 1.7.2. is it any problem with the versions?
Thanks in Advance.
Has anyone been able to find a way to test pdf's with ruby within the browser? I have tried a few different ways and the only way I have been able to get any pdf testing to work is to save off the pdf and use the pdf_reader gem. This only seems to work on pdf's that, when the link is clicked, opens up a dialog box with the options to open or save the pdf. Unfortunately I have not been able to find a way to do anything like this with pdf's that are opened in browser, with no dialog box options to save it. Any ideas?
Maybe testing it in the browser isnt the best way. When you say test the pdf what are you trying to do? I wouldnt test the pdf in the browser if I was you.
Try docsplit, if you want to verify its contents.
Docsplit is a command-line utility and Ruby library for splitting apart documents into their component parts: searchable UTF-8 plain text via OCR if necessary, page images or thumbnails in any format, PDFs, single pages, and document metadata (title, author, number of pages...)
You are not inventing a browser, or a PDF generator.
Use unit tests to check your back-end modules can take data in, and write PDF out, then serve the PDF in a website and let the browser do its thing. Test (as what Rails calls a "functional test") that the MVC will produce a web page containing a link to the PDF, and you are done.
You can use gem 'mechanize' to download an online PDF (the PDF with in a browser) on your computer and then read it via gem PDF reader.