qaf getting started tutorial provides step by step exercise
This repository provides a step by step guide to start using QAF.
- Create locator repository
- Create your first Test case in BDD
- Create your first Test case in Java
- References
After completion of Exercise-1 you will have your local enviroment ready with project skeleton in eclipse. Now you are ready to create your first automated test.
In this exercise we will create sample test case to automate google serach. Conisder following test case:
Open Google search page
Search for Git reporsitory QMetry Automation Framework
Verify that Git repository link present
To start with first of all you need to identify element locators and place into locator repositoiry. QAS user can use object-spy featuer and non QAS users can use firebug with firepath.
Create new locator repository named home.properties
and provide locators for serach box, and search button.
txt.searchbox = name=q
btn.search = name=btnG
- Create new BDD file named
suite-1.bdd
in scenarios dir - Open this file in BDD editor
- Create new Scenario with name 'SampleTest', Description 'Sample Test Scenario' and group 'SMOKE'.
- if you are using QAS create new scenario following new scenario wizard
- if you are using eclipse with QAF bdd editor press ctrl+space and select Scenario snnipet
- You will have scenario skeleton ready as below:
SCENARIO: SampleTest
META-DATA: {"description":"Sample Test Scenario","groups":["SMOKE"]}
END
-
Call teststeps in your Scenario. To start with for this example of google you can call predefined steps avialable with QAF-Support jar (Make sure that ivy has QAF-Support dependency added). Call steps as bellow
SCENARIO: SampleTest META-DATA: {"description":"Sample Test Scenario","groups":["SMOKE"]} Given get '/' When sendkeys 'Git reporsitory QAF' to 'txt.searchbox' And click on 'btn.search' Then verify link with partial text 'qaf' is present END
- Create new Java Class
Suite1.java
extending 'com.qmetry.qaf.automation.ui.WebDriverTestCase' under packageqaf.example.tests
in src dir. Refer Creating a Java class for help. Your class should look like:
package qaf.example.tests;
import org.testng.annotations.Test;
import com.qmetry.qaf.automation.ui.WebDriverTestCase;
public class Suite1 extends WebDriverTestCase {
}
- create new test method
SampleTest
, add import statementimport org.testng.annotations.Test;
, provide@Test
annotation, set decription and groups
@Test(description="Sample Test Scenario", groups={"SMOKE"})
public void testGoogleSearch() {
}
- add import statement
import static com.qmetry.qaf.automation.step.CommonStep.*;
. Use content assist (ctrl + SPACE) to refer available methods. Call steps in test method as bellow:
get("/");
sendKeys("Git reporsitory QAF", "txt.searchbox");
click("btn.search");
verifyLinkWithPartialTextPresent("qaf");
your complete class with testcase will look like
package qaf.example.tests;
import org.testng.annotations.Test;
import com.qmetry.qaf.automation.ui.WebDriverTestCase;
public class Suite1 extends WebDriverTestCase {
@Test(description="Sample Test Scenario", groups={"SMOKE"})
public void testGoogleSearch() {
get("/");
sendKeys("Git reporsitory QAF", "txt.searchbox");
click("btn.search");
verifyLinkWithPartialTextPresent("qaf");
}
}