I am looking for a way to automate couple of browsers... Firefox and Chrome (for now on just Windows) from an external application/process.
Is there a way to do things along these lines:
Start the browser with a URL
Have the browser load up the page, run script etc.
Inspect the DOM
For reference, IE can be automated using the InternetExplorer.Application object which can be created in a shell script using the following javascript, and then I can walk the DOM API:
var ie = new ActiveXObject('InternetExplorer.Application');
The motivating scenario here is automated testing. I'd like to load up the page containing the test code, and gather results after the test has run.
http://watin.sourceforge.net/
WatiN does exactly that, and I believe they recently added Chrome support
Update 6/22/2011:
Currrently WatiN only works on Firefox 2 and 3, not in Firefiox 4 (and almost certainly not in Firefox 5, which was released today). Also, the time of this answer, Chrome support was supposedly being added, but it looks like that never got fully baked and now is not listed as a suported platform on their home page.
Also worth noting, in my experience WatiN got a lot slower when I upgraded to IE9. I saw this on two different machines, and downgrading to IE8 sped the tests back up on both machines.
I still use WatiN heavily, but now mostly for behavior driven design and functional regression testing, which generally are not browser-specific. Then, manually test in FF and Chrome for all progression testing.
Update 9/22/2015:
Elmue is right, it looks like WatiN is no longer being worked on. We've looking into Selenium for our automated acceptance tests now: http://www.seleniumhq.org
TestR will let you automated IE, FF, and Chrome. I've started working on Edge support but just haven't had the time.
https://github.com/BobbyCannon/TestR
You can use the nuget package.
https://www.nuget.org/packages/TestR/
Here is some examples.
https://docs.epiccoders.com/Page/35/TestR
Related
A company I applied to had sent me a "test", which I had to decline, due to it not making a lot of sense: They asked me to use Selenium to test a Win desktop app GUI and produce bug reports in the table form. They claimed that they're using Selenium to test Win desktop applications in their company, but they wouldn't tell how.
I did some research, and my understanding is that Selenium works with web browsers only, as it's been specifically designed for this. How can it connect to Windows desktop app? I just don't see any way possible for this. I found a claim that some integrate it with another open source tool to do this, but this "test" was supposed to take 1 hour of my time and installing some other framework, configuring, integrating with Selenium, etc, etc definitely wouldn't fall into one hour time frame. I had heard from another company too, that they wanted me to use Selenium to automate non-browser stuff if they hired me... Still have no clue about this--is this even possible? -- or is it something simply wrong?
You can't. Selenium can only automate web browsers, and even then, only certain browsers (Chrome, Firefox, Internet Explorer, Opera, and occasionally Safari). It interacts with them at a very deep level, very specific to the browser in question, in ways that don't apply to other Windows applications.
Selenium is meant for GUI tests of web applications and nothing else. But you can include Sikuli in webdriver code and can test the any of the applications either desktop or web applications, since it uses Image recognition.
else if you want to test the desktop application using Selenium thne u need to import Autoit and can test those as well
There's one feature in my web application which requires a small browser plug-in to work. 99% of the application is ASP.NET + javascript and we have no skills in writing browser plug-ins or any interest in training someone to maintain it so I've used freelancer web sites with great success to get a working firefox plug-in/add-on/extension.
However, the new Firefox rapid release schedule is throwing this whole plan into disarray because every new version of firefox seems to need a new extension. This is not just to do with the em:maxVersion versions in the RDF file; the plugin actually refuses to load, so it seems that every 6 weeks I will have to commission a freelancer to update the plug-in for the next version of Firefox. From my limited understanding this is because each version of gecko is not compatible with the previous one.
I can't help but think I'm missing something here. For instance, the IE plugin was written in about 2005 for IE6 and we have never needed to touch it; it still works with IE9. Is it really the case that all firefox plug-ins have to be rewritten every 6 weeks, or am I doing something wrong?
The basic function of the plug-in is to use a windows timer to poll shared memory and then traverse the DOM to find a page with a specific javascript function which it then calls.
So my question is, is there any way that I can make a firefox plug-in with a more reasonable lifespan (i.e. year or more), or am I stuck with having to release a new one every time a new version of firefox comes out?
The best way to avoid compatibility issues with Firefox addons when using binary code ( c / c++ ) is to use JSCtypes. Here is a recent overview of how this works:
http://blog.mozilla.com/dwitte/2010/03/12/extension-authors-browser-hackers-meet-js-ctypes/
Here is an entry point to the MDN documentation on JSCtypes:
https://developer.mozilla.org/en/js-ctypes
To avoid this long-term problem with compatibility, I would make a port of your C++ code to jsctypes from xpcom a hard requirement for the contractors you are working with.
I found this plugin, for Firefox, on Google and it looks like perfect to test if my site works well on all major browsers. It changes the browser's user-agent and emulates almost all versions of all browsers on any OS, including mobile. Looks like perfect. My question is: can i trust 100% on this plugin? It really give me the same effect as if i were using other browser (ie6 for exemple)?
It really give me the same effect as if i were using other browser (ie6 for exemple)?
No. Changing the user-agent string does not mean you are changing the browser's rendering engine - it just sends a different browser signature to the server. The actual rendering will always be Firefox's, at the sites will always look as they do in Firefox.
See these questions on how to test sites in different browsers:
Browser testing - Ideas on how to tackle it efficiently
https://stackoverflow.com/questions/464089/simulators-emulators-for-mobile-browser-testing
It does not affect the rendering engine of your browser. It only pretends to the server to be a different browser, so if the server has e.g. a special IE6-optimized version it will send you this version instead.
Essentially, this is mostly useful to access web pages that claim to not support your browser by pretending that you have a supported version.
For testing cross-browser compatibility it is useless.
You can get free screenshots from a wide array of browsers at http://browsershots.org/
that is a very useful site, but won't help you test JavaScript interactions.
I've recently started using watir-webdriver and so far am a big fan. However I need to be able to test Safari too, and I don't have access to a mac to be able to use Safari-Watir.
Does anyone know a good alternative to use for testing Safari on a windows machine? (In Ruby of course)
Thanks
(important, see UPDATE below)
the Selenium Webdriver folks are apparently waiting for something from Apple in order to support safari. I would not hold your breath.
Apple does have a version of Safari for the PC, I'm not sure how good the current version is, the initial releases were.. um, well, lets just say they had issues (lots of issues)
Personally (mostly for security reasons) I would not run it nor recommend anyone use it for any purpose other than downloading Chrome or Firefox. But unfortunately a lot of apple users use it because it's what came with their systems, which means to the extent apple users are part of your target market, you have to test on it.
For the moment that means you'll need to use Safariwatir, which has not as far as I can tell had an update for a year or more.
the current state of support on both the Selenium/Webdriver side and the Safariwatir side was discussed recently in this thread in the watir general group on google
UPDATE
Webdriver now has Safari support, which makes direct support of safari (I think on a mac only at this point) possible. See http://watirmelon.com/2012/04/17/using-watir-webdriver-with-safari-at-last/ for more info.. still a bit DYI but I'm sure it will get more accessable soon.
Mike, seems this is available now. Alister Scott wrote up some instructions on his blog Using Watir-Webdriver with Safari At Last
Unfortunately this still a bit DYI because you have to build your own safari extension, which requires getting certificates and such from apple, and I'm not sure if you can create the right environment to build that stuff on anything other than a mac.
I always have to check each and every browser to see if my website would work. Is there a website where I can check it with?
Update:
I don't really want just screenshots (which what browsershots do), I want to actually test the posting of my script.
You want a web site to check your web site for javascript compatibility? How would you expect it to know how to exercise your interface to trigger the proper interactions? Or are you thinking of it doing some sort of static code analysis? I think you are better off coding against a framework that has solved most of the browser-dependent idiosyncrasies and using it to check for browser capabilities before you use them. jQuery, MooTools, Prototype/Scriptaculous, etc. go a long way in solving these problems for javascript.
Note that you still need to worry about rendering your site, but you already have several answers for how to go about doing that based on web sites. Personally, I just maintain IE/Safari/FF/Opera/Chrome on my workstation and do significant checking in IE/FF and basic checking in Safari/Opera/Chrome.
Even when there exist websites that allow you to see a static snapshot of your site in several browsers, you should really test your page on them yourself, because there can be subtle, and not so subtle, bugs and differences that are only apparent when interacting with the webpage.
You can cover yourself quite a lot by testing in
A Gecko engine browser (Firefox)
A Webkit engine browser (Chrome, Safari, Konqueror)
Opera
AND IE6+
John Resig recommends checking the Yahoo graded browser support documentation.
If you write unit tests for your javascript, you could use testswarm http://testswarm.com
There are multiple options:
http://ipinfo.info/netrenderer/
These site will let you run multiple browsers and version without installing. You only need to install a plugin
http://spoon.net/browsers/
There are plenty of sites, just Google/Bing for browser compatibility check.
http://browsershots.org/ is a good one.
Although most of them just take a snapshot of the site, you might have to do the manual check for things like menus and dynamic content.
BrowserShots might do what you want if you can tell by rendering a particular URL whether or not things will work as expected.
In light of your update, you could still use BrowserShots by creating a page which tests each of your scripts and renders 'pass' or 'fail' as its content depending on whether they work or not.
Failing that, Multiple IE is quite useful for running various versions of IE on one PC which can otherwise be problematic.