2. Selenium Framework : Maven with (Selenium and TestNG and JDBC drivers)
1. Maven -> used to build and manage dependency (pom.xml)
2. TestNG -> provided @Test, @Before, Assert functionalities and also we can run test cases as TestNG (single or bulk (testng.xml) )
3. Selenium -> Used to interact with browser and do actions.
4. JDBC driver -> If needed some times for testing with databases, other wise its optional
Project path -
https://drive.google.com/file/d/1skGf29LRdaoB3e5XlAwIxW50LAArLnVZ/view?usp=sharing
1. How to install Maven and set the path in environmental
variable
2. Add selenium and maven dependencies on pom.xml
3. How to Add TestNG in Eclipse
4. How to write Page Object Model Structure in code.
JAVA
Set java env variables:
JAVA_HOME=C:\Program
Files\Java\jdk1.8.0_191
PATH=C:\Program
Files\Java\jdk1.8.0_191\bin
Verify in cmd -> java –version
MAVEN
Extract and keep it in -> C:\Maven\apache-maven-3.6.0
Set env variable
PATH=C:\Maven\apache-maven-3.6.0\bin;
Eclipse
Create “Maven Project” ->
In Pom.xml -> add selenium dependency
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.5</version>
</dependency>
In Pom.xml -> add testNG dependency
<groupId>org.testng</groupId>
|
<artifactId>testng</artifactId>
|
Add driver -> driver/chromedriver.exec
Install
TestNg as eclipse plugin
Eclipse -> help -> Eclipse Marketplace -> search
"testng" -> install "TestNG
Verify TestNg installed
Windows -> show view -> other
-> under Java -> TestNG
Eclipse
Inside Maven -> create 3 packages (business, page,
regression)
Business -> for
business logic like filling the UI elements
Page -> to
have all the components ready with ID or XPATH
Regression -> To
write the test cases like MyTest.java (which has @Test)
Inside package -> create corresponding classes with @Test and selenium code
1.
Run in TestNG
Once everything is ready
Rtclk on MyTest.java (which has @Test annotation) -> Run
as -> TestNG
1.
Run in Maven
Make sure you have 3 configurations fine.
1.
Test case should end with “Test” -> Eg “MyTest.java” , “FirstPageTest.java”
2.
Selenium, TestNG dependency added in pom.xml
3.
“M2_REPO” is added in Libraries section as shown
below.
Rtclk on Project -> Run as -> Maven test
Errors Faced during project Run:
1. [ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
2 FAILED: runTest
org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot navigate to invalid URL"}
Solution : check url is proper or not.. (mainly check url contain "https://" )
3. FAILED: runTest
java.lang.IllegalStateException: The driver executable does not exist: C:\Users\Lavanya\eclipse-workspace1\Forms\.\drivers1\chromedriver.exe
Solution: check path of driver is proper or not... (eg: whether driver is in \drivers folder or not etc..)