Before creating maven projection In eclipse IDE for selenium webdriver, You must survive aware nigh maven as well as It should survive Installed properly In your eclipse IDE. Earlier nosotros learnt nigh what Is maven In THIS POST as well as how to download as well as Install maven In THIS POST. So If maven Is Installed In eclipse as well as thus y'all are create to create novel maven projection every bit described In bellow given steps.
Steps to create novel maven project
Step 1 : First of all, Open eclipse IDE as well as acquire for creating novel projection from New -> Other every bit shown In bellow Image.
It volition opened upwards novel projection creation window.
Step ii : Expand Maven folder In novel projection creation sorcerer window as well as select Maven Project as well as and thus click on Next button every bit shown In bellow Image.
It volition stimulate got y'all to projection get upwards as well as place choice screen.
Step 3 : On project get upwards as well as place choice screen, You tin pick out run infinite place for maven projection past times clicking on browse button. If wants to purpose default run infinite place as well as thus select that banking concern lucifer box as well as click on Next button every bit bellow.
It volition stimulate got y'all to Archetype choice screen.
Steps 4 : On Archetype choice screen, Select Maven-archetype-quickstart choice every bit bellow as well as click on Next button.
Step 5 : On side past times side screen, Enter Group Id = STTA, Artifact Id = MavenProject and Package = STTA.MavenProject as shown In bellow Image. Then click on Finish button.
It volition create novel maven projection In eclipse every bit bellow.
Now your maven projection Is created. You tin encounter in that place Is pom.cml file nether your projection every bit shown above.
Step 6 : Now y'all take away to add together selenium webdriver as well as TestNG dependencies amongst latest version In pom.xml file. Open pom.xml file as well as copy-paste bellow given code In It as well as and thus salve It.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>STTA</groupId> <artifactId>MavenProject</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>MavenProject</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.44.0</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8.8</version> <scope>test</scope> </dependency> </dependencies> </project>
Current latest version of selenium webdriver Is 2.44.0. TestNG latest version Is 6.8.8. You tin alter It If version updated version liberate In future.
Step 7 : Delete existing AppTest.java file from src/testjava folder packet as well as create novel flat file nether same packet amongst get upwards = WebDriverTest.java every bit bellow.
Now copy-paste bellow given code In that WebDriverTest.java file as well as salve It.
package STTA.MavenProject; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; populace flat WebDriverTest { WebDriver driver; @Test populace void verifySearch() { driver = novel FirefoxDriver(); driver.get("http://only-testing-blog.blogspot.in/"); driver.quit(); } }
Above file volition present y'all errors every bit nosotros create non stimulate got Included selenium as well as testng jounce files In project's create path. Here maven volition create It automatically for us.
When y'all salve It, It volition kickoff edifice run infinite past times downloading required jounce files from maven fundamental repository as well as shop In local repository based on your selenium webdriver as well as TestNG versions every bit bellow. It tin stimulate got five to twenty minutes based on your Internet speed.
Running webdriver projection from pom.xml file
When higher upwards procedure acquire completed, You tin run your projection from pom.xml file. To run It, Right click on pom.xml file as well as select Run As -> Maven test every bit shown In bellow Image.
It volition kickoff executing webdriver test WebDriverTest.java file. This Is the agency to create as well as run webdriver exam In eclipse using maven as well as testng.
http://www.software-testing-tutorials-automation.com/