-
Lets add Selenium and TestNg Maven dependencies
in pom.xml
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
</dependencies>
-
The moment you add above code in pom.xml, IDE
starts to download the said jars
-
Now maven dependencies looks like this.
Java
coding part:
-
Now create packages for Page object model as
shown below.
-
Driver object creation
o
MyDriver.java contains only Driver object related
stuff
-
Now, Lets work on POM
o
What is POM : Segregating Locators , pages and
Tests related to each page for better maintenance.
- HomePageLocators
- HomePage
- HomePageTests
o
Locators:
§
This this the palace where all your Specific
page level locators exists.
o
Pages:
§
This is the places where all your specific page
level locators exists
o
Tests:
§
This is the places where all your specific page
level Test cases exists
Do you want to see the code?
Here is it.
https://github.com/kasthurikranthikumar/selenium-pom-sample
-
For Running the project:
o
Right click on POM.xml and select maven test
-
If you are facing any issues please check below
points
o
Make sure you had an entry in pom.xml which is
related to testing dependency
o
You test class file must end with Test
o
M2_Maven variable must be added