Oct
17
2007
If you want to test for the presence of an image in a page using selenium, the best way to do this is by using the assertAttribute function. This function takes two parameters: an attribute locater and a pattern to which it should match. So for the following HTML…
<html>
<body>
<img src="http://192.168.1.163/files/rous.jpg"/>
<body/>
<html/>
You can check that the image is there by calling “assertAttribute” with “//img@src” and “http://*/files/rous.jpg” as your params. This of course is only checking the HTML. If the image file actually doesn’t exist on the server and is displayed as a lovely red x in the browser, selenium will happily pass this test case.
no comments | posted in selenium
Jul
23
2007
If you’re developing a web app that has a SSL certificate and for whatever reason the url being used to access the app doesn’t match the one stored in the certificate, then you’ll get a little warning message from the browser (example taken from FireFox):
You have attempted to establish a connection with “url-used-in-the-browser”. However, the security certificate presented belongs to “url-defined-in-the-certificate”. It is possible, though unlikely, that someone may be trying to intercept your communication with this site.
Most of the time, this invalid certificate warning is merely an annoyance. By clicking “OK” you can continue to the site without having to worry about the certificate problem for the remainder of the session. But if you are attempting to run automated Selenium tests against your web app, this little warning prompt is troublesome.
Selenium is an awesome test framework that uses JavaScript to run tests against your web app. By loading a single url in your browser, Selenium can run a whole suite of tests. But if there’s a ssl cert warning message, everything grinds to a halt. Unfortunately Selenium’s JavaScript can’t click the “OK” button to get past the message. This is bad if your tests are running automatically.
A solution to this problem is to use FireFox with the Remember Mismatched Domains (RMD) addon. This awesome addon written by Andrew Lucking gives the user the option to remember which url’s loaded into the browser have mismatched ssl certificates. Now once you “OK” one of these urls, you have to option to have FireFox remember. From that point on, you won’t end up with that pesky little warning message.
And if you’re running FireFox on OS X, check out this blog post or click here to install RMD for FireFox on OS X.
8 comments | posted in selenium