|
FrequentlyAskedQuestions
WebDriver FAQs
FAQQ: What is WebDriver? A: WebDriver is a tool for writing automated tests of websites. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application. Q: So, is it like Selenium? Or Sahi? A: The aim is the same (to allow you to test your webapp), but the implementation is different. Rather than running as a Javascript application within the browser (with the limitations this brings, such as the "same origin" problem), WebDriver controls the browser itself. This means that it can take advantage of any facilities offered by the native platform. Q: What is Selenium 2.0? A: WebDriver will soon become part of Selenium. The main contribution that WebDriver will make is its API and the native drivers. The process of rolling WebDriver into Selenium will probably take some time, so until it's complete if you'd like to use the WebDriver API then the best bet will be to use WebDriver directly. There's an introduction to this at the Google Open Source blog. Q: What's the plan for migrating WebDriver into Selenium? A: The process is being discussed on the OpenQA forum, but the current plan is that parts of WebDriver will be rolled into Selenium 1.5. For the user, the key change will be that the WebDriver interfaces will become available within the Selenium (RC) libraries. There will also be a series of changes internally, for example picking the WebDriver implementation of the Selenium interfaces where this is appropriate, and these changes will be discussed and tracked on the OpenQA site and/or the WebDriver mailing list. Q: What does it mean to be "developer focused"? A: We believe that within a software application's development team, the people who are best placed to build the tools that everyone else can use are the developers. Although it should be easy to use WebDriver directly, it should also be easy to use it as a building block for more sophisticated tools. Because of this, WebDriver has a small API that's easy to explore by hitting the "autocomplete" button in your favourite IDE, and aims to work consistently no matter which browser implementation you use. Q: How do I execute Javascript directly? A: We believe that most of the time there is a requirement to execute Javascript there is a failing in the tool being used: it hasn't emitted the correct events, has not interacted with a page correctly, or has failed to react when an XmlHttpRequest returns. We would rather fix WebDriver to work consistently and correctly than rely on testers working out which Javascript method to call. We also realise that there will be times when this is a limitation. As a result, for those browsers that support it, you can execute Javascript by casting the WebDriver instance to a JavascriptExecutor. In Java, this looks like: WebDriver driver; // Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return document.title");Other language bindings will follow a similar approach. Take a look at the UsingJavascript page for more information. Q: Which browsers does WebDriver support? A: The existing drivers are the InternetExplorerDriver, FirefoxDriver and HtmlUnitDriver. For more information about each of these, including their relative strengths and weaknesses, please follow the links to the relevant pages. Q: My XPath finds elements in one browser, but not in others. Why is this? A: The short answer is that each supported browser handles XPath slightly differently, and you're probably running into one of these differences. The long answer is on the XpathInWebDriver page. Q: The InternetExplorerDriver does not work well on Vista. How do I get it to work as expected? A: There are a number of solutions:
Q: What about support for languages other than Java? A: Python support is already available. Support for other languages is planned, and we will be announcing these on the mailing list as they are checked in. Q: How do I handle pop up windows? A: WebDriver offers the ability to cope with multiple windows. This is done by using the "WebDriver.switchTo().window()" method to switch to a window with a known name. If the name is not known, you can use "WebDriver.getWindowHandles()" to obtain a list of known windows. Q: Does WebDriver support Javascript alerts and prompts? A: Not yet, but we plan on adding an API for this, that will look something like: // Get a handle to the open alert, prompt or confirmation Alert alert = driver.switchTo().alert(); // Get the text of the alert or prompt alert.getText(); // And acknowledge the alert (equivalent to clicking "OK") alert.accept(); Q: The "onchange" event doesn't fire after a call "sendKeys" A: WebDriver leaves the focus in the element you called "sendKeys" on. The "onchange" event will only fire when focus leaves that element. As such, you need to move the focus, perhaps using a "click" on another element. Q: I'm using NX to connect to my Linux session, and the Linux firefox browser isn't starting, with an error about not being able to connect A: The normal reason for this is that the DISPLAY and XAUTH environment variables aren't set up quite right. If you've started your NX session in headless mode, running a single command, make sure that the command starts with executing the "nxxauth" program (on my system, to start the KDE console app, I use: /usr/NX/bin/nxxauth konsole) Q: I'd like it if WebDriver did.... A: If there's something that you'd like WebDriver to do, or you've found a bug, then please add an add an issue to the WebDriver project page. Q: Why Is The InternetExplorerDriver Called Jobbie? A: It started out as a play on "jacobie". It's not terribly funny, I know, but it made sense at the time and the name has stayed. |
Sign in to add a comment
Is it like JWebUnit?
i also wonder what's the difference between webdriver and jwebunit..
Can Web Driver be used to simulate load on a web page?
Is there an IDE provided for record and play?
Thanks so much for your efforts building this tool. Actually, I was trying to find a solution for ExtJS and was directed here. Is there a way to handle ExtJS in WebDriver??
Can WebDriver? handle mouse events?? I am stuck .. please help
Please ask additional questions at the webdriver group: http://groups.google.com/group/webdriver There are more people who read that group who can help answer your questions.