-
Notifications
You must be signed in to change notification settings - Fork 10
Sahagin Overview
The short answer is, "The tool which generates readable tabular test result report from the Selenium WebDriver test programs whose method definitions have the description annotations".
Although there are many tabular test script maintenance tools such as Selenium IDE, Sahagin is characteristic in that it makes test scripts readable without losing the "flexible descriptive power" and the "maintainability" provided by the programming language as much as possible.
Let's dig in with some examples.
If you use WebDriver, it is recommended to create a class for each web page and define all page actions on it to reduce the cost of test script maintenance. This design pattern is called page object pattern, and this is popular in test automation.
If you adopt this pattern, add @TestDoc annotation and description to each method defined on each page class.
@PageDoc("Contact page")
public class ContactPage {
private WebDriver wd;
public ContactPage(WebDriver wd) {
this.wd = wd;
}
@TestDoc("set name '{name}'")
public void setName(String name) {
wd.findElement(By.name("your-name")).clear();
wd.findElement(By.name("your-name")).sendKeys(name);
}
...
@TestDoc("send inquiry")
public void send() {
wd.findElement(By.cssSelector(
"input.wpcf7-submit")).click();
}
}Use the page class in test script to interact with the web pages.
@Test
public void inquiryTest_1() {
wd.get("http://www-demo.trident-qa.com/en/contact/");
ContactPage contact = new ContactPage(wd);
contact.setName("test user");
contact.setMail("***@***.com");
contact.setOrganization("TRIDENT Inc.");
contact.setSubject("test");
contact.setMessage("this is test inquiry");
contact.send();
}After executing the test, the HTML report is generated.
Sahagin automatically adds description to the basic operations such as click or sendKeys. You don't need to add @TestDoc annotations to these operations.
@Test
public void inquiryTest_2() {
wd.get("http://www-demo.trident-qa.com/en/contact/");
wd.findElement(By.name("your-name")).clear();
wd.findElement(By.name("your-name")).sendKeys("test user");
wd.findElement(By.name("your-email")).clear();
wd.findElement(By.name("your-email")).sendKeys("***@***.com");
wd.findElement(By.name("your-organization")).clear();
wd.findElement(By.name("your-organization")).sendKeys("TRIDENT Inc.");
wd.findElement(By.name("your-subject")).clear();
wd.findElement(By.name("your-subject")).sendKeys("test");
wd.findElement(By.name("your-message")).clear();
wd.findElement(By.name("your-message")).sendKeys("this is test inquiry");
wd.findElement(By.cssSelector("input.wpcf7-submit")).click();
}
You have created your own test framework or wrapper and use it? No problem. Simply add the @TestDoc annotation to the method of your test framework.
@TestDoc("click element 'css = {cssSelector}'")
public void clickByCss(String cssSelector) {
wd.findElement(By.cssSelector(cssSelector)).click();
}
@TestDoc("set text '{text}' to element 'name = {name}'")
public void setTextByName(String name, String text) {
wd.findElement(By.name(name)).clear();
wd.findElement(By.name(name)).sendKeys(text);
}@Test
public void inquiryTest_3() {
wd.get("http://www-demo.trident-qa.com/en/contact/");
setTextByName("your-name", "test user");
setTextByName("your-email", "***@***.com");
setTextByName("your-organization", "TRIDENT Inc.");
setTextByName("your-subject", "test");
setTextByName("your-message", "this is test inquiry");
clickByCss("input.wpcf7-submit");
}
You don't need to stop using your own method or superclass. Sahagin can be easily integrated into other existing various frameworks.
Sahagin HTML report can show test method call hierarchy.
You can check your common methods detail easily, and this makes it easy for you to understand the test script detail.
Sahagin automatically takes screen captures for each test step annotated with @TestDoc and for test failures.
You can easily check the each test step behaviour on HTML report by moving cursor by the up or down arrow key.
The error line is shown in red on the HTML report.
You can add the link to the Sahagin report of each test script on the Jenkins JUnit format test report page by the Sahagin Jenkins plugin.
The combination of Jenkins test report and Sahagin report will make it easy to investigate test failures, and to share automated scenario details with your customers or other developers.
The current latest version of Sahagin-Java supports:
- Java1.8 or later
- JUnit4, JUnit3, TestNG
- Selenium WebDriver, FluentLenium, Appium, Selendroid, ios-driver
For supported environments of Sahagin-Groovy, see here.
If you want support for other test frameworks or languages, please request us by creating new issue.
Sahagin is designed to be easily extended to other Java test frameworks or other programming languages such as Ruby or Python.
The next step is Getting started.