forcedotcom/aura — pull request #27 by gabrielsuch (2014-10-10 00:45:42+00:00)
Title: PageObject pattern support

Hi there,

I am a Salesforce new hire and I was doing the Aura101 exercise,
so I start doing some refactoring in the tests to introduce PageObject pattern,
but since that WebDriver instantiation is encapsulated by WebDriverTestCase it becomes quite hard.

I have created some support classes to make it easier and I'll try to show why it's pretty cool.
The two main classes are: PageObjectTestCase and AuraPageObject.

PageObjectTestCase extends WebDriverTestCase, so it keeps all the current behaviour and add strongly typed support for the ObjectPage pattern.

```
public class SampleUITest extends PageObjectTestCase {
public SampleUITest(String name) {
super(new SamplePageObject(name));
}

public void testExample() throws Exception {
page().open();
page().doSomething();
page().doAnotherAction();

// asserts
}
}
```
We can encapsulate all the page logic inside AuraPageObject, and reuse this object in multiples tests.

```
public class SamplePageObject extends AuraPageObject {

public SamplePageObject(String name) {
super(name);
}

public void open() {
getDriver().get("myURL"); // getDriver() is injected by WebDriverTestCase automatically
}

}
```

Those are just some simple test support classes, but in my opinion it helps a lot the introduction of PageObject pattern.

Thanks,
Gabriel Such