I'd like to know if using a headless browser, (such as phantomJS) with RSelenium significanly faster than running scripts with a regular browser (such as chrome)? Also driving it directly or using a selenium server ?
Is there a short function to check/plot difference in speeds?
Related
I've done a lot of searches. But I haven't found how to set chrome web driver to use proxy yet.
I've found people using phantomjs:
Setting proxy in RSelenium with PhantomJS
and people using Firefox:
Using Rselenium with firefox and socks5h
But I've found no one using chrome yet. And strangely, there is a makeFirefoxProfile() but no makeChromeProfile function. So doing it this way is not applicable.
Back to the question. Is there a way to set proxy for chrome in Selenium? Thanks!
Wanted to know how do you handle iframe using Watir WebDriver.
I am trying to automate a SalesForce based app which runs in a console mode.
All the GUI elements of the web applications are within iFrames.
The issue we are facing is the automated tests run perfectly fine in case of FireFox but when we try to run the same scripts in Chrome (using ChromeDriver ChromeDriver 2.20) the user action of selecting links within iFrames are not being performed.
Any idea if this is an issue/bug with the Chromedriver 2.20 being used.
Thanks,Umesh
How do I use Robot Framework Selenium to control a regular browser that I can see, and that doesn't exit after finishing a test?
You can't. You cannot get a handle on an already open browser. You can, however, open your browser with the test and then not close it. The browser will remain open for you to interact with it.
If you absolutely must have this functionality, you could try using the remote library interface. The remote library could act as a proxy to the selenium keywords. It could open a browser and keep it open for as long as the remote library server is running. My guess is that this would take a lot of work, and I don't see any real benefit in doing it.
I have my resume online in an html page (www.mysite.com/resume.html). Every time I need a PDF version of it, I use Google Chrome's print dialog to save it as a PDF, which uses my print CSS stylesheet.
I want to be able to navigate to www.mysite.com/resume.pdf to always have an up to date PDF version without having to go through Google Chrome manually. Is there a way to programmatically and automatically create a resume.pdf from resume html? If I can write a script that runs once every 24 hours or something like that, that would be good.
PhantomJS is perfect for this. It invokes an instance of WebKit from the command line which can then be used to output to file such as PDF.
PhantomJS:
http://phantomjs.org/
Specific instructions for exporting screen output to a file:
http://phantomjs.org/screen-capture.html
e.g.:
phantomjs rasterize.js 'http://www.example.com/resume.html' resume.pdf
Chrome has started headless program.
With that, we can create a pdf. e.g. for windows navigate your commandline to
C:\Users\{{your_username}}\AppData\Local\Google\Chrome SxS\Application>
Then hit the command:
chrome --headless --print-to-pdf="d:\\{{path and file name}}.pdf" https://google.com
If you are looking to do this server-side via PHP might I recommend the Browsershot library which leverages the Puppeteer (NodeJS package) and Chrome / Chromium headless browser?
It works really well. Way easier to install and get going than wkhtmltopdf (which is another option that doesn't rely on a NodeJS package nor the Chrome/Chromium headless browser. Personally, I recommend Browsershot solution since wkhtmltopdf has some issues depending on the type of server (Linux distro and version) you're running. That is, the only reliable way to install wkhtmltopdf that I've found is to download and compile from source on the server that you're running and not through a package manager).
Also, if you happen to be needing a solution specifically while working on a Laravel project then there's a wrapper library for Browsershot available.
Check out this tutorial to get started.
I'm writing tests using webdriver in Java.
Is there a way to run browsers (ff / ie) in headless mode in a windows box?
I cant use a linux box and HtmlUnitDriver is not helping as our webapp has many ajax controls.
I have started a small project to supply a driver for WebDriver using SimpleBrowser. You may want to check it out: https://github.com/Teun/SimpleBrowser.WebDriver
It's still early days though. I would appreciate help in the form of contributions and testing.
At this point there is no headless version that I am aware of the Firefox or IE. Since Firefox is open source it's possible that you could get the source code for that browser and then remove the UI portion but there are a few problems with it that I can see. First you have to build a custom app to setup your own load testing engine. Second you are locked to one web render, though I think chrome is open source as well but it doesn't play as nicely as Firefox or IE (using the system .dlls vs. a custom executable). Third without a lot of testing I am sure there will be stability issues and potentially other unforseen issues with this option. That being said there is a .net headless browser that's fairly simple and would probably be decent for load testing called simple browser. However it depends on what you are wanting to load. If you just looking for bandwidth and server load then you should be find using multiple instances of the browser. I would be curious to know if using the headless browser in this fashion if you instantiated different WebDriver if it would play nicely. i.e.
WebDriver driver1 = new SimpleBrowser();
WebDriver driver2 = new SimpleBrowser();
.
.
.
.
.
WebDriver driver[n] = new SimpleBrowser();
and then you could run [n] parallel tests. Also of note in the above code SimpleBrowser() doesn't hook directly to the WebDriver interface you would have to Extend the interface to reference that .dll
Start the test program as a Windows service and the browsers will run just fine, even on a machine with no monitors. Technically speaking, they're running in a "session" that is disconnected, but it's essentially what you mean by "headless".
HtmlUnitDriver does support ajax, and can run in both java and c# (if ported via IKVM).
There is, however, no way to run IE and FF in headless mode. I can't tell you how many times I've wished for that...