As part of our open-source advocacy here in G2iX, and as part of promoting our consulting and training services, we've recently started to provide free webinars about automated testing using Selenium.
In these webinars, I talk about why we've chosen Selenium as our weapon of choice when it comes to automated testing of web application. I spend a substantial fraction of time demonstrating what Selenium can do, and what results and reports it can provide. Finally, I wrap up by tackling the role of manual testing and by providing guidelines on when to automate.
At the end of each webinar, questions are entertained. Here are some of the past questions:
Q: Do you run your Selenium scripts each night?
A: For some of our projects, we run the scripts on a daily basis, especially if regression bugs are highly to occur.
Q: Can Selenium support mobile browsers?
A: We haven't tried using Selenium with mobile browsers. However, if a mobile browser supports Javascript, theoretically, it may work with Selenium RC since Selenium is written in Javascript.
Q: How would you effectively write scripts when you can only use XPath as the locator?
A: The problem with XPath locators is they depend of the structure of the HTML page. In short, they change a lot during development. What we do is we assign locators to variables. This way, we only have to update them in one place.
Q: We have encountered issues with XPath with IE. It doesn't seem to work. Have you encountered this?
A: IE handles XPath differently than Firefox. IE is usually slower. Sometimes, it is unable to find the XPath expression. If possible, use id or name attributes, or CSS selectors. If you have to use XPath, avoid full XPath expressions. For exmaple, try to start your XPath expression with a parent element.
Q: Can Selenium do image comparison tests?
A: Selenium doesn't provide this on its own. What Selenium RC can do is return images on the web page to the programming language, which, coupled with an image processing library, can do image comparison tests.
Q: Do you have to model out your entire application first when you automate it using Selenium RC and Ruby?
A: Nope, you don't have to. You can just code your Selenium actions in a linear fashion directly inside your tests/specs.
Q: How do you go about timing issues, e.g. asynchronous calls?
A: This is where the isElementPresent command comes in. Instead of waiting/sleeping for a set number of seconds, you can tell Selenium to wait for the presence (or absecnce) of a particular element before proceeding to the next action, since this usually signals the end of an asynchronous call.
Q: Could you recommend a good Java test framework for Selenium RC?
A: My colleages here have switched to TestNG from JUnit. They prefer its features like skipping of test methods, annotations, test method dependency, grouping, and reports.
Q: How does testing with Selenium compare to unit-testing with QUnit, PHPunit, etc?
A: Selenium tests most, if not all, of the application stack, unlike unit-testing which tests small individual units of source code. However, Selenium can be used with the different unit testing frameworks.
We're looking forward to receiving more questions in the succeeding webinars.
