Project base for automated testing using Selenium & java. To show the application in action, several pages and page fragments for https://www.saucedemo.com/ have been implemented.
-
Use Selenium with Page Object Model (POM) pattern.
-
Avoiding calling
Thread.sleep(…)
in favor ofWebDriverWait.until(…)
with custom expected conditions. -
WebDriver injected into test classes:
-
We can define the implementation and configuration of WebDriver in a test XML file,
-
We can reuse WebDriver in all test scope classes.
-
-
Reports with Allure framework.
Look at the testng.xml file. In the configuration file, we can specify the browser and its configuration to be used in the test.
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >
<suite name="all">
<!-- run tests on Firefox with a FullHD window size -->
<test name="test1">
<parameter name="browser" value="firefox FullHD"/>
<classes>
<class name="mk.automation.test.LoginTest"/>
</classes>
</test>
<!-- run tests on Chrome with a default window size -->
<test name="test2">
<parameter name="browser" value="chrome"/>
<classes>
<class name="mk.automation.test.LoginTest"/>
</classes>
</test>
<!-- run tests on Chrome with a window size 800x600 -->
<test name="test3">
<parameter name="browser" value="chrome 800x600"/>
<classes>
<class name="mk.automation.test.LoginTest"/>
<class name="mk.automation.test.ProductsPageTest"/>
</classes>
</test>
</suite>
The list of interesting classes:
-
Page.java - base class for all page classes.
-
Fragment.java - base class for page fragments used multiple times on one or more pages.
-
UrlConditions.java - example of custom "expected conditions" used to wait for something.
-
LoginPage.java - sample class representing a page.
-
ProductsPage.java - sample class representing a page with fragments.
-
ItemFragment.java - sample page fragment class.
-
ProductsPageTest.java - sample test class.