Доклад о том, как еще можно организовать автоматизацию тестирования веб-сервисов, а именно, приспособить подход/шаблон Page Object (казалось бы, причем тут он?). Главное достоинство подхода - его максимальная простота и дружелюбность. Мы рассмотрим живой и успешно работающий на реальном проекте фреймворк, построенный подобным образом, разберём на слои, обсудим плюсы, минусы и саму идею подхода в целом.
3. The goals
After this presentation you will have one more (of first one) practical example
of implementing test automation framework for testing web services, that:
- is easy to understand for you and newcomers
- was implemented on practice and have shown good results
- requires minimal technical expertise from your side
4. Starting conditions - what did I have
- No test automation on a stream (sub-project)
- Some kind of automation on other streams
- Customer wants BDD + Scrum process
- Some freedom of choice inside the stream
- Junior newcomers
5. Web services test automation tools and why I didn’t take them
- Custom KDT approach (TAF + Excel)
- SoapUI (SoapUITestCaseRunner for Java)
- JAXB: WSDL (or builder pattern) => POJO
6. ’Classic’ test framework layers in UI test automation
Test scripts
Services
Page-objects
WebDriver
7. ’Classic’ page-object example
public class LoginPage extends Page {
private static final By INPUT_LOGIN_LOCATOR = By.xpath("//input[@name='login']");
private static final By INPUT_PASSWORD_LOCATOR = By.xpath("//input[@name='passwd']");
private static final By BUTTON_SUBMIT_LOCATOR = By.xpath("//span/button[@type='submit']");
public void open() {
driver.get(URL);
}
public void typeUserName(String userName) {
driver.findElement(INPUT_LOGIN_LOCATOR).sendKeys(userName);
}
public void typePassword(String password) {
driver.findElement(INPUT_PASSWORD_LOCATOR).sendKeys(password);
}
public void clickSubmit() {
driver.findElement(BUTTON_SUBMIT_LOCATOR).click();
}
}
8. Our test framework layers
Test scripts
Step definitions
RX objects
Xml modifier
22. XmlHelper
public class XmlHelper {
private static final String NODE_NAME_REGEX =
"(?<!['"][w/-]{1,255})(?<=[(/[:]|(and|or)s)[a-z_]+b(?![(':-])";
private static final String FORMATTING_PATTERN = "*[local-name()='%s']";
private static String makeXpathLocatorNameSpaceIgnoring(String xpathLocator) {…}
private static NodeList getNodeListByXpath(Document doc, String locator) {…}
private static Node getXmlNodeByXpath(Document doc, String locator) {…}
public static boolean isNodePresent(Document doc, String locator) {…}
public static String getNodeText(Document doc, String locator) {…}
public static void changeNodeInDocument(Document doc, String locator, String value) {…}
public static int countNodesInDocument(Document doc, String locator) {…}
public static void removeNodeFromDocument(Document doc, String locator) {…}
public static void duplicateNodeInDocument(Document doc, String locator) {…}
...
...
...
23. Benefits of this approach
- very simple to understand, read and write tests (KISS principle)
- has lower entrance level
- friendly for automation engineers without experience in web services testing
- doesn’t need WSDL’s that are not always available
- was successfully implemented on real project and shows good results