Friday, February 18, 2011

It is time to admit - Continuous Deployment is replacing Continuous Integration.

Tuesday, November 02, 2010

Great prediction (made back in 2006) of  commercial test automation tools - and it is now true! The prove of this is in another post from the same blog - Do Testers Have to Write Code? which is a great research of current trends for tester skills.

And I totally agree with the following quote from that article:

...record and playback is overrated. It’s fine for creating throwaway scripts, and for creating a first draft script that you then refactor without mercy until it doesn’t even resemble the original recording. But record and playback is not a test automation strategy. It is at best a tool and at worst a crutch. Be wary of record and playback.

Tuesday, August 31, 2010

Using Page Object pattern for Web Application testing with WebDriver


The Page Objects is a great pattern for automated testing of any GUI application, both desktop and web. In a nutshell the Page Object is a class that represents the page (or window for the desktop application) of the Application under the Test (AUT). The automated test interacts with the page through the page object instance.

The following example uses WebDriver, Java and TestNG and wil "test" the Google Mail login page.

First, we need to create a page object for the login page. We will use http://mail.google.com as the start page.

package demo.pageobects;

import org.openqa.selenium.RenderedWebElement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
public class GmailLoginPage {
/** User name field*/
@FindBy (id = "Email")
private RenderedWebElement userNameField;

/** Password field */
@FindBy (id = "Passwd")
private RenderedWebElement passwordField;

/**
* Create the page object for the Gmail Login Page
*
* @param driver WebDriver instance
*/
public GmailLoginPage(WebDriver driver) {
driver.get("http://mail.google.com");
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 15), this);
}

/**
* Login to Gmail as <code>username</code> with <code>password</code>
*

* @param username
* @param password
*/
public void login(String username, String password) {
// In case if there are previously entered values,
// clear the fields
userNameField.clear();
passwordField.clear();

// Type user name and password
userNameField.sendKeys(username);
passwordField.sendKeys(password);

// Submit user name and password
userNameField.submit();
}
}

Then we will use this page object in our test class:

package demo.pageobects;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class GmailLoginPageTest {
private WebDriver driver;

@BeforeClass
public void initWebDriver() {
driver = new InternetExplorerDriver();
}

@AfterClass
public void quitDriver() {
driver.quit();
}

@Test
public void testLogin() {
GmailLoginPage page = new GmailLoginPage(driver);
page.login("user@gmail.com", "password");
}

}


Of course this example is very simple. In your real test the login method should return the instance of another page object (i.e. InboxPage) or the new instance of the GmailLoginPage if login failed.

Monday, February 01, 2010

VirtualBox Headless and Vista

So you are trying to run a VirtualBox in headless mode on your Windows Vista and then connect to it using Remote Desktop Connection (RDC)? And when you try to connect to the localhost you get the following error message: Your computer could not connect to another console session on the remote computer because you already have a console session in progress.

You should specify different port for your VM (default is 3389), for example:
VBoxHeadless -s your_vm_name -p 5029

and connect to localhost:5029 via RDC. You were unable to connect because Vista (and Windows 7 as well) refuses connections from localhost.