├── .DS_Store
├── .gitignore
├── ExtentReports.zip
├── ExtentReports
├── .DS_Store
├── AutomationReport.html
├── Mac_OS_X_Thu_Feb_24_00_02_55_IST_2022_AutomationReport.html
├── Mac_OS_X_Tue_Feb_22_16_21_59_IST_2022_AutomationReport.html
├── Mac_OS_X_Tue_Feb_22_18_21_15_IST_2022_AutomationReport.html
├── Mac_OS_X_Tue_Feb_22_21_09_55_IST_2022_AutomationReport.html
├── Mac_OS_X_Wed_Feb_23_23_52_55_IST_2022_AutomationReport.html
└── Mac_OS_X_Wed_Feb_23_23_55_47_IST_2022_AutomationReport.html
├── README.md
├── pom.xml
└── src
├── main
└── java
│ └── com
│ └── learning
│ ├── annotations
│ └── FrameworkAnnotation.java
│ ├── config
│ ├── ConfigFactory.java
│ └── FrameworkConfig.java
│ ├── constants
│ └── FrameworkConstants.java
│ ├── driver
│ ├── Driver.java
│ ├── DriverFactory.java
│ ├── DriverFactoryLocal.java
│ ├── DriverFactoryRemote.java
│ └── DriverManager.java
│ ├── enums
│ ├── AuthorType.java
│ ├── CategoryType.java
│ └── WaitType.java
│ ├── exceptions
│ ├── FrameworkException.java
│ ├── InvalidPathForExtentReportFileException.java
│ ├── InvalidPathForFilesException.java
│ └── InvalidRemoteWebDriverURLException.java
│ ├── java_Mail_API
│ ├── EmailAttachmentsSender.java
│ └── EmailConfig.java
│ ├── listeners
│ ├── MethodInterceptor.java
│ └── TestListener.java
│ ├── pages
│ ├── HomePage.java
│ ├── LoginPage.java
│ └── components
│ │ ├── FooterMenuComponent.java
│ │ └── TopMenuComponent.java
│ ├── reports
│ ├── ExtentLogger.java
│ ├── ExtentManager.java
│ └── ExtentReport.java
│ ├── rough
│ ├── ConfigLoaderUsingOwner.java
│ ├── DataSupplierTest.java
│ ├── JavaFakerAPI.java
│ └── datasupplier_excel
│ │ ├── DataSupplierTest_Excel.java
│ │ ├── DataSupplierTest_Excel2.java
│ │ └── TestData_Rough.java
│ ├── testdata
│ └── TestData.java
│ └── utils
│ ├── BrowserInfoUtils.java
│ ├── BrowserOSInfoUtils.java
│ ├── DataProviderUtils.java
│ ├── DateUtils.java
│ ├── EmailSendUtils.java
│ ├── IconUtils.java
│ ├── OSInfoUtils.java
│ ├── ReportUtils.java
│ ├── ScreenshotUtils.java
│ ├── SeleniumUtils.java
│ ├── VerificationUtils.java
│ └── ZipUtils.java
└── test
├── .DS_Store
├── java
├── .DS_Store
└── com
│ └── learning
│ └── tests
│ ├── BaseTest.java
│ ├── DashboardApplyLeaveTest.java
│ ├── DashboardMyTimesheetTest.java
│ ├── HomePageTest.java
│ ├── LoginTest.java
│ └── LogoutTest.java
└── resources
├── .DS_Store
├── config
└── config.properties
├── runners
├── testng.xml
└── testng_SAFARI.xml
└── testdata
├── .DS_Store
├── testData.xlsx
└── testData_rough.xlsx
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/TMB_SeleniumFramework2/99452e2b553199c1dcf6a24dfbc06ae16fcc5771/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Project exclude paths
2 | /target/
3 | .idea
4 | .settings
5 | ExtentReports
6 | target
7 | test-output
8 | z_others
9 | ExtentReports.zip
10 |
--------------------------------------------------------------------------------
/ExtentReports.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/TMB_SeleniumFramework2/99452e2b553199c1dcf6a24dfbc06ae16fcc5771/ExtentReports.zip
--------------------------------------------------------------------------------
/ExtentReports/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/TMB_SeleniumFramework2/99452e2b553199c1dcf6a24dfbc06ae16fcc5771/ExtentReports/.DS_Store
--------------------------------------------------------------------------------
/ExtentReports/Mac_OS_X_Tue_Feb_22_18_21_15_IST_2022_AutomationReport.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | threadLocal = new ThreadLocal<>();
23 |
24 | public static WebDriver getDriver() {
25 | return threadLocal.get();
26 | }
27 |
28 | public static void setDriver(WebDriver driver) {
29 | threadLocal.set(driver);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/enums/AuthorType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.enums;
12 |
13 | /**A Java Enum is a special Java type used to define collections of constants.*/
14 | public enum AuthorType {
15 | RAJAT,
16 | NISHANT,
17 | GAUTAM,
18 | PANKAJ
19 | }
--------------------------------------------------------------------------------
/src/main/java/com/learning/enums/CategoryType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.enums;
12 |
13 | /**A Java Enum is a special Java type used to define collections of constants.*/
14 | public enum CategoryType {
15 | REGRESSION,
16 | SMOKE,
17 | SANITY,
18 | BVT
19 |
20 | }
--------------------------------------------------------------------------------
/src/main/java/com/learning/enums/WaitType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.enums;
12 |
13 | public enum WaitType {
14 | //Enum -> Set of constants
15 | PRESENCE,
16 | CLICKABLE,
17 | VISIBLE;
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/exceptions/FrameworkException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.exceptions;
12 |
13 | /**
14 | * FrameworkException extends RuntimeException - because I want to terminate the program when the Exception
15 | * comes
16 | */
17 | @SuppressWarnings("serial")
18 | public class FrameworkException extends RuntimeException {
19 |
20 | public FrameworkException(String message) {
21 | super(message);
22 | }
23 |
24 | public FrameworkException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/exceptions/InvalidPathForExtentReportFileException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.exceptions;
12 |
13 | @SuppressWarnings("serial")
14 | public class InvalidPathForExtentReportFileException extends InvalidPathForFilesException {
15 |
16 | public InvalidPathForExtentReportFileException(String message) {
17 | super(message);
18 | }
19 |
20 | public InvalidPathForExtentReportFileException(String message, Throwable cause) {
21 | super(message, cause);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/exceptions/InvalidPathForFilesException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.exceptions;
12 |
13 | @SuppressWarnings("serial")
14 | public class InvalidPathForFilesException extends FrameworkException {
15 |
16 | public InvalidPathForFilesException(String message) {
17 | super(message);
18 | }
19 |
20 | public InvalidPathForFilesException(String message, Throwable cause) {
21 | super(message, cause);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/exceptions/InvalidRemoteWebDriverURLException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.exceptions;
12 |
13 | @SuppressWarnings("serial")
14 | public class InvalidRemoteWebDriverURLException extends FrameworkException {
15 |
16 | public InvalidRemoteWebDriverURLException(String message) {
17 | super(message);
18 | }
19 |
20 | public InvalidRemoteWebDriverURLException(String message, Throwable cause) {
21 | super(message, cause);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/java_Mail_API/EmailAttachmentsSender.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.java_Mail_API;
12 |
13 | import java.io.IOException;
14 | import java.util.Date;
15 | import java.util.Properties;
16 |
17 | import javax.mail.Authenticator;
18 | import javax.mail.Message;
19 | import javax.mail.MessagingException;
20 | import javax.mail.Multipart;
21 | import javax.mail.PasswordAuthentication;
22 | import javax.mail.Session;
23 | import javax.mail.Transport;
24 | import javax.mail.internet.AddressException;
25 | import javax.mail.internet.InternetAddress;
26 | import javax.mail.internet.MimeBodyPart;
27 | import javax.mail.internet.MimeMessage;
28 | import javax.mail.internet.MimeMultipart;
29 |
30 | /**
31 | * https://www.codejava.net/java-ee/javamail/send-e-mail-with-attachment-in-java
32 | */
33 | public class EmailAttachmentsSender {
34 |
35 | /**
36 | * i) Send n no. of Attachments
37 | *
38 | * ii) Format set for TC count
39 | *
40 | * iii) Send mail to n no. of Users
41 | */
42 | public static void sendEmailWithAttachments(String host, String port, final String userName, final String password,
43 | String[] toAddress, String subject, String message, String... attachFiles)
44 | throws AddressException, MessagingException {
45 | // sets SMTP server properties
46 |
47 | Properties properties = new Properties();
48 | properties.put("mail.smtp.host", host);
49 | properties.put("mail.smtp.port", port);
50 | properties.put("mail.smtp.auth", "true");
51 | properties.put("mail.smtp.starttls.enable", "true");
52 | properties.put("mail.user", userName);
53 | properties.put("mail.password", password);
54 |
55 | // creates a new session with an authenticator
56 | Authenticator auth = new Authenticator() {
57 | public PasswordAuthentication getPasswordAuthentication() {
58 | return new PasswordAuthentication(userName, password);
59 | }
60 | };
61 | Session session = Session.getInstance(properties, auth);
62 |
63 | // creates a new e-mail message
64 | Message msg = new MimeMessage(session);
65 |
66 | msg.setFrom(new InternetAddress(userName));
67 |
68 | InternetAddress[] addressTo = new InternetAddress[toAddress.length];
69 | for (int i = 0; i < toAddress.length; i++)
70 | addressTo[i] = new InternetAddress(toAddress[i]);
71 | msg.setRecipients(Message.RecipientType.TO, addressTo);
72 |
73 | /*
74 | * InternetAddress[] toAddresses = { new InternetAddress(toAddress) };
75 | * msg.setRecipients(Message.RecipientType.TO, toAddresses);
76 | */
77 | msg.setSubject(subject);
78 | msg.setSentDate(new Date());
79 |
80 | // creates message part
81 | MimeBodyPart messageBodyPart = new MimeBodyPart();
82 | messageBodyPart.setContent(message, "text/html");
83 |
84 | // creates multi-part
85 | Multipart multipart = new MimeMultipart();
86 | multipart.addBodyPart(messageBodyPart);
87 |
88 | // adds attachments
89 | if (attachFiles != null && attachFiles.length > 0) {
90 | for (String filePath : attachFiles) {
91 | MimeBodyPart attachPart = new MimeBodyPart();
92 |
93 | try {
94 | attachPart.attachFile(filePath);
95 | } catch (IOException ex) {
96 | ex.printStackTrace();
97 | }
98 |
99 | multipart.addBodyPart(attachPart);
100 | }
101 | }
102 |
103 | // sets the multi-part as e-mail's content
104 | msg.setContent(multipart);
105 |
106 | // sends the e-mail
107 | Transport.send(msg);
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/java_Mail_API/EmailConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.java_Mail_API;
12 |
13 | import static com.learning.constants.FrameworkConstants.PROJECT_NAME;
14 |
15 | /**
16 | * Data for Sending EMail after execution
17 | */
18 | public class EmailConfig {
19 |
20 | public static final String SERVER = "smtp.gmail.com";
21 | public static final String PORT = "587";
22 |
23 | public static final String FROM = "testtmail95@gmail.com";
24 | public static final String PASSWORD = "*****";
25 |
26 | /* "**********@gmail.com", "**********@jetblue.com"*/
27 | public static final String[] TO = {"testtmail95@gmail.com"};
28 | public static final String SUBJECT = PROJECT_NAME;
29 | }
--------------------------------------------------------------------------------
/src/main/java/com/learning/listeners/MethodInterceptor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.listeners;
12 |
13 | import java.util.ArrayList;
14 | import java.util.HashSet;
15 | import java.util.List;
16 | import java.util.Set;
17 |
18 | import org.testng.IMethodInstance;
19 | import org.testng.IMethodInterceptor;
20 | import org.testng.ITestContext;
21 | import org.testng.annotations.Test;
22 |
23 | public class MethodInterceptor implements IMethodInterceptor {
24 |
25 | @Override
26 | public List intercept(List methods, ITestContext context) {
27 |
28 | System.out.println("----------------METHOD INTERCEPTOR--------------------------");
29 | System.out.println("methods: " + methods);
30 |
31 | List result = new ArrayList();
32 |
33 | // System.setProperty("testCategory", "BVT,Smoke");
34 | String testCategory = System.getProperty("testCategory");
35 | System.out.println("testCategory: " + testCategory);
36 | for (IMethodInstance method : methods) {
37 | Test testMethod = method.getMethod().getConstructorOrMethod()
38 | .getMethod().getAnnotation(Test.class);
39 | Set groups = new HashSet();
40 | for (String group : testMethod.groups()) {
41 | groups.add(group);
42 | }
43 | // if (groups.contains("SMOKE")) {
44 | // if (groups.contains("BVT")) {
45 | if (groups.contains(testCategory)) {
46 | result.add(method);
47 | }
48 | }
49 | if (testCategory == null) {
50 | System.out.println(
51 | "Either You are not running the test execution from Maven"
52 | + " command line or you are not giving the property -DtestCategory");
53 | return methods;
54 | } else {
55 | return result;
56 | }
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/listeners/TestListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.listeners;
12 |
13 |
14 | import java.util.Arrays;
15 |
16 | import com.learning.annotations.FrameworkAnnotation;
17 | import com.learning.config.ConfigFactory;
18 | import com.learning.reports.ExtentLogger;
19 | import com.learning.reports.ExtentReport;
20 | import com.learning.utils.BrowserOSInfoUtils;
21 | import com.learning.utils.EmailSendUtils;
22 | import com.learning.utils.IconUtils;
23 | import com.learning.utils.ZipUtils;
24 | import org.testng.ISuite;
25 | import org.testng.ISuiteListener;
26 | import org.testng.ITestListener;
27 | import org.testng.ITestResult;
28 |
29 | import com.aventstack.extentreports.markuputils.ExtentColor;
30 | import com.aventstack.extentreports.markuputils.Markup;
31 | import com.aventstack.extentreports.markuputils.MarkupHelper;
32 |
33 | import static com.learning.constants.FrameworkConstants.*;
34 |
35 | public class TestListener implements ITestListener, ISuiteListener {
36 |
37 | static int count_passedTCs;
38 | static int count_skippedTCs;
39 | static int count_failedTCs;
40 | static int count_totalTCs;
41 |
42 | @Override
43 | public void onStart(ISuite suite) {
44 | ExtentReport.initReports();
45 | }
46 |
47 | @Override
48 | public void onFinish(ISuite suite) {
49 | ExtentReport.flushReports();
50 | ZipUtils.zip();
51 | EmailSendUtils.sendEmail(count_totalTCs, count_passedTCs, count_failedTCs, count_skippedTCs);
52 | }
53 |
54 | @Override
55 | public void onTestStart(ITestResult result) {
56 |
57 | // System.out.println("onTestStart() ");
58 | count_totalTCs = count_totalTCs + 1;
59 | ExtentReport.createTest(result.getMethod().getMethodName());
60 | // ExtentReport.createTest(result.getMethod().getDescription());
61 |
62 | ExtentReport.addAuthors(result.getMethod().getConstructorOrMethod().getMethod()
63 | .getAnnotation(FrameworkAnnotation.class).author());
64 |
65 | ExtentReport.addCategories(result.getMethod().getConstructorOrMethod().getMethod()
66 | .getAnnotation(FrameworkAnnotation.class).category());
67 |
68 | ExtentReport.addDevices();
69 | // ExtentLogger.info("" +
70 | // BrowserOSInfoUtils.getOS_Browser_BrowserVersionInfo() + "");
71 | ExtentLogger.info(BOLD_START + IconUtils.getOSIcon() + " & " + IconUtils.getBrowserIcon() + " --------- "
72 | + BrowserOSInfoUtils.getOS_Browser_BrowserVersionInfo() + BOLD_END);
73 |
74 | // ExtentLogger.info(ICON_Navigate_Right + " Navigating to : " + BOLD_START +
75 | // ConfigFactory.getConfig().url() + BOLD_END);
76 |
77 | String url=ConfigFactory.getConfig().url();
78 | ExtentLogger.info(ICON_Navigate_Right + " Navigating to : " + url + "");
79 |
80 | }
81 |
82 | @Override
83 | public void onTestSuccess(ITestResult result) {
84 | count_passedTCs = count_passedTCs + 1;
85 | String logText = "" + result.getMethod().getMethodName() + " is passed." + " " + ICON_SMILEY_PASS;
86 | Markup markup_message = MarkupHelper.createLabel(logText, ExtentColor.GREEN);
87 | //ExtentLogger.pass(markup_message);
88 | ExtentLogger.pass(markup_message, true);
89 | }
90 |
91 | @Override
92 | public void onTestFailure(ITestResult result) {
93 | count_failedTCs = count_failedTCs + 1;
94 | ExtentLogger.fail(ICON_BUG + " " + "" + result.getThrowable().toString() + "");
95 | String exceptionMessage = Arrays.toString(result.getThrowable().getStackTrace());
96 | String message = " Exception occured, click to see details: "
97 | + ICON_SMILEY_FAIL + " " + "
" + exceptionMessage.replaceAll(",", "
")
98 | + " \n";
99 |
100 | ExtentLogger.fail(message);
101 |
102 | String logText = BOLD_START + result.getMethod().getMethodName() + " is failed." + BOLD_END + " " + ICON_SMILEY_FAIL;
103 | Markup markup_message = MarkupHelper.createLabel(logText, ExtentColor.RED);
104 | ExtentLogger.fail(markup_message, true);
105 |
106 | }
107 |
108 | @Override
109 | public void onTestSkipped(ITestResult result) {
110 |
111 | count_skippedTCs = count_skippedTCs + 1;
112 |
113 | ExtentLogger.skip(ICON_BUG + " " + "" + result.getThrowable().toString() + "");
114 | // ExtentLogger.skip("" + result.getThrowable().toString() + "");
115 | String logText = "" + result.getMethod().getMethodName() + " is skipped." + " " + ICON_SMILEY_FAIL;
116 | Markup markup_message = MarkupHelper.createLabel(logText, ExtentColor.YELLOW);
117 | ExtentLogger.skip(markup_message, true);
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/pages/HomePage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.pages;
12 |
13 | import com.learning.enums.WaitType;
14 | import com.learning.pages.components.FooterMenuComponent;
15 |
16 | import static com.learning.utils.SeleniumUtils.*;
17 |
18 | import com.learning.pages.components.TopMenuComponent;
19 | import org.openqa.selenium.By;
20 |
21 |
22 | public class HomePage {
23 |
24 | //HomePage HAS-A TopMenu --> Composition
25 | //HomePage IS-A Page --> Inheritance
26 | private TopMenuComponent topMenuComponent;
27 | private FooterMenuComponent footerMenuComponent;
28 |
29 | public HomePage() {
30 | topMenuComponent = new TopMenuComponent();
31 | footerMenuComponent = new FooterMenuComponent();
32 | }
33 |
34 | private static final By WELCOME = By.id("welcome");
35 | private static final By LOGOUT = By.xpath("//a[normalize-space()='Logout']");
36 |
37 | private static final By DASHBOARD_MY_TIMESHEET = By.xpath("//span[normalize-space()='My Timesheet']");
38 | private static final By DASHBOARD_APPLY_LEAVE = By.xpath("//span[normalize-space()='Apply Leave']");
39 |
40 |
41 | public void clickOnAdmin() {
42 | topMenuComponent.clickAdmin();
43 | }
44 |
45 | public String getFooterText() {
46 | return footerMenuComponent.getFooterLable();
47 | }
48 |
49 |
50 | public String getHomePageTitle() {
51 | // return DriverManager.getDriver().getTitle();
52 | // return getPageTitle();
53 | // return SeleniumUtils.getPageTitle();
54 | return getPageTitle();
55 | }
56 |
57 | private HomePage clickOnWelcome() {
58 | click(WELCOME, WaitType.CLICKABLE);
59 | return this;
60 | }
61 |
62 | private LoginPage clickOnLogout() {
63 | click(LOGOUT, WaitType.CLICKABLE);
64 | return new LoginPage();
65 | }
66 |
67 | //Wrapper method for performing 2 operations
68 | public LoginPage logoutFromApplication() {
69 | // clickOnWelcome();
70 | // waitForGivenTime(2);
71 | // return clickOnLogout();
72 |
73 | //Method Chaining
74 | return clickOnWelcome()
75 | .clickOnLogout();
76 | }
77 |
78 | public HomePage clickOnMyTimeSheet() {
79 | click(DASHBOARD_MY_TIMESHEET, WaitType.CLICKABLE);
80 | return this;
81 | }
82 |
83 | public HomePage clickOnApplyLeave() {
84 | click(DASHBOARD_APPLY_LEAVE, WaitType.CLICKABLE);
85 | return this;
86 | }
87 |
88 | public String getPageURL() {
89 | return getWebPageURL();
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/pages/LoginPage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.pages;
12 |
13 | import static com.learning.utils.SeleniumUtils.*;
14 |
15 | import com.learning.enums.WaitType;
16 | import org.openqa.selenium.By;
17 | import org.openqa.selenium.WebElement;
18 |
19 | public class LoginPage {
20 |
21 | // By txtBoxUsername = By.id("txtUsername");
22 | // By txtBoxPassword = By.id("txtPassword");
23 | // By btnLogin = By.id("btnLogin");
24 |
25 | // private By txtBoxUsername = By.id("txtUsername");
26 | // private By txtBoxPassword = By.id("txtPassword");
27 | // private By btnLogin = By.id("btnLogin");
28 |
29 | // private final By txtBoxUsername = By.id("txtUsername"); //100 threads --> 100 times
30 | // private final By txtBoxPassword = By.id("txtPassword");
31 | // private final By btnLogin = By.id("btnLogin");
32 |
33 | //static --> Used for Memory management efficiency
34 | // private static final By txtBoxUsername = By.id("txtUsername"); //100 threads --> 1 txtBoxUsername
35 | // private static final By txtBoxPassword = By.id("txtPassword");
36 | // private static final By btnLogin = By.id("btnLogin");
37 |
38 | //Naming Convention for private static final fields/variables
39 | private static final By TXTBOX_USERNAME = By.id("txtUsername"); //100 threads --> 1 txtBoxUsername
40 | private static final String TXTBOX_USERNAME_TXT = "Username";
41 |
42 | private static final By TXTBOX_PASSWORD = By.id("txtPassword");
43 | private static final String TXTBOX_PASSWORD_TXT = "Password";
44 |
45 | private static final By BTN_LOGIN = By.id("btnLogin");
46 | private static final String BTN_LOGIN_TXT = "Login Button";
47 |
48 | private static final By MSG_ERROR = By.id("spanMessage");
49 | //private static final String MSG_ERROR_TXT = "Error Message";
50 |
51 |
52 |
53 | // public void setUsername(String username) {
54 | // DriverManager.getDriver().findElement(txtBoxUsername).sendKeys(username);
55 | // }
56 |
57 | // public LoginPage setUsername(String username) {
58 | private LoginPage setUsername(String username) {
59 | // DriverManager.getDriver().findElement(TXTBOX_USERNAME).sendKeys(username);
60 | // sendKeys(TXTBOX_USERNAME, username);
61 | // SeleniumUtils.sendKeys(TXTBOX_USERNAME, username);
62 | //sendKeys(TXTBOX_USERNAME, username);
63 | sendKeys(TXTBOX_USERNAME, username, TXTBOX_USERNAME_TXT);
64 |
65 | // return new LoginPage();
66 | return this;
67 | }
68 |
69 | public WebElement getTxtBoxUserame(){
70 | return getElement(TXTBOX_USERNAME);
71 | }
72 | public WebElement getTxtBoxPassword(){
73 | return getElement(TXTBOX_PASSWORD);
74 | }
75 | public WebElement getBtnLogin(){
76 | return getElement(BTN_LOGIN);
77 | }
78 |
79 | private LoginPage setPassword(String password) {
80 | //DriverManager.getDriver().findElement(TXTBOX_PASSWORD).sendKeys(password);
81 | //sendKeys(TXTBOX_PASSWORD, password);
82 | //SeleniumUtils.sendKeys(TXTBOX_PASSWORD, password);
83 | // sendKeys(TXTBOX_PASSWORD, password);
84 | sendKeys(TXTBOX_PASSWORD, password, TXTBOX_PASSWORD_TXT);
85 | return this;
86 | }
87 |
88 | private HomePage clickLogin() {
89 | //DriverManager.getDriver().findElement(BTN_LOGIN).click();
90 | // click(BTN_LOGIN);
91 | //SeleniumUtils. click(BTN_LOGIN);
92 | // click(BTN_LOGIN);
93 | //click(BTN_LOGIN, WaitType.CLICKABLE);
94 | //click(BTN_LOGIN, WaitType.CLICKABLE);
95 | click(BTN_LOGIN, WaitType.CLICKABLE, BTN_LOGIN_TXT);
96 | return new HomePage(); //Page Chaining
97 | }
98 |
99 | //Wrapper method for performing 3 operations
100 | public HomePage loginToApplication(String username, String password) {
101 | //Method Chaining
102 | return setUsername(username)
103 | .setPassword(password)
104 | .clickLogin();
105 | }
106 |
107 | public String getErrorMessage(){
108 | return getElementText(MSG_ERROR);
109 | }
110 |
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/pages/components/FooterMenuComponent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.pages.components;
12 |
13 | import static com.learning.utils.SeleniumUtils.*;
14 |
15 | import org.openqa.selenium.By;
16 |
17 | public class FooterMenuComponent {
18 |
19 | private static final By LABEL_FOOTER_MESSAGE = By.id("footer");
20 |
21 | public String getFooterLable() {
22 | //return DriverManager.getDriver().findElement(labelFooterMessage).getText();
23 | // return getElementText(LABEL_FOOTER_MESSAGE);
24 | // return SeleniumUtils.getElementText(LABEL_FOOTER_MESSAGE);
25 | return getElementText(LABEL_FOOTER_MESSAGE);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/pages/components/TopMenuComponent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.pages.components;
12 |
13 | import static com.learning.utils.SeleniumUtils.*;
14 |
15 | import com.learning.enums.WaitType;
16 | import org.openqa.selenium.By;
17 |
18 | public class TopMenuComponent {
19 |
20 | private static final By LNK_ADMIN = By.id("menu_admin_viewAdminModule");
21 | private static final String LNK_ADMIN_TXT = "Link: Admin";
22 |
23 | public TopMenuComponent clickAdmin() {
24 | // DriverManager.getDriver().findElement(lnkAdmin).click();
25 | // click(LNK_ADMIN);
26 | //SeleniumUtils.click(LNK_ADMIN);
27 | //click(LNK_ADMIN);
28 | click(LNK_ADMIN, WaitType.CLICKABLE, LNK_ADMIN_TXT);
29 | return this;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/reports/ExtentLogger.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.reports;
12 |
13 | import com.aventstack.extentreports.MediaEntityBuilder;
14 | import com.aventstack.extentreports.markuputils.Markup;
15 | import com.learning.config.ConfigFactory;
16 | import com.learning.utils.ScreenshotUtils;
17 |
18 | import static com.learning.constants.FrameworkConstants.*;
19 |
20 | //final -> We do not want any class to extend this class
21 | public final class ExtentLogger {
22 |
23 | //private -> We do not want anyone to create the object of this class
24 | private ExtentLogger() {
25 | }
26 |
27 | public static void pass(String message) {
28 | ExtentManager.getExtentTest().pass(message);
29 | }
30 |
31 | public static void pass(Markup message) {
32 | ExtentManager.getExtentTest().pass(message);
33 | }
34 |
35 | public static void fail(String message) {
36 | ExtentManager.getExtentTest().fail(message);
37 | }
38 |
39 | public static void fail(Markup message) {
40 | ExtentManager.getExtentTest().fail(message);
41 | }
42 |
43 | public static void skip(String message) {
44 | ExtentManager.getExtentTest().skip(message);
45 | }
46 |
47 | public static void skip(Markup message) {
48 | ExtentManager.getExtentTest().skip(message);
49 | }
50 |
51 | public static void info(Markup message) {
52 | ExtentManager.getExtentTest().info(message);
53 | }
54 |
55 | public static void info(String message) {
56 | ExtentManager.getExtentTest().info(message);
57 | }
58 |
59 | public static void captureScreenshot() {
60 | ExtentManager.getExtentTest().info("Capturing Screenshot",
61 | MediaEntityBuilder.createScreenCaptureFromBase64String(ScreenshotUtils.getBase64Image()).build());
62 | }
63 |
64 | public static void pass(String message, boolean isScreeshotNeeded) {
65 | if (ConfigFactory.getConfig().passed_steps_screenshot().trim().equalsIgnoreCase(YES) && isScreeshotNeeded) {
66 | ExtentManager.getExtentTest().pass(message,
67 | MediaEntityBuilder.createScreenCaptureFromBase64String(ScreenshotUtils.getBase64Image()).build());
68 | } else {
69 | pass(message);
70 | }
71 | }
72 |
73 | public static void pass(Markup message, boolean isScreeshotNeeded) {
74 | if (ConfigFactory.getConfig().passed_steps_screenshot().trim().equalsIgnoreCase(YES) && isScreeshotNeeded) {
75 | /* System.out.println("----------------");
76 | System.out.println("ConfigFactory.getConfig().passed_steps_screenshot() = " + ConfigFactory.getConfig().passed_steps_screenshot());
77 | System.out.println("ConfigFactory.getConfig().passed_steps_screenshot().trim().equalsIgnoreCase(YES) = " + ConfigFactory.getConfig().passed_steps_screenshot().trim().equalsIgnoreCase(YES));
78 | System.out.println("isScreeshotNeeded = " + isScreeshotNeeded);
79 | */
80 | ExtentManager.getExtentTest().pass(
81 | MediaEntityBuilder.createScreenCaptureFromBase64String(ScreenshotUtils.getBase64Image()).build());
82 | ExtentManager.getExtentTest().pass(message);
83 | } else {
84 | pass(message);
85 | }
86 | }
87 |
88 | public static void fail(String message, boolean isScreeshotNeeded) {
89 | if (ConfigFactory.getConfig().failed_steps_screenshot().trim().equalsIgnoreCase(YES) && isScreeshotNeeded) {
90 | ExtentManager.getExtentTest().fail(message,
91 | MediaEntityBuilder.createScreenCaptureFromBase64String(ScreenshotUtils.getBase64Image()).build());
92 | } else {
93 | fail(message);
94 | }
95 | }
96 |
97 | public static void fail(Markup message, boolean isScreeshotNeeded) {
98 | if (ConfigFactory.getConfig().failed_steps_screenshot().trim().equalsIgnoreCase(YES) && isScreeshotNeeded) {
99 | ExtentManager.getExtentTest().fail(
100 | MediaEntityBuilder.createScreenCaptureFromBase64String(ScreenshotUtils.getBase64Image()).build());
101 | ExtentManager.getExtentTest().fail(message);
102 | } else {
103 | fail(message);
104 | }
105 | }
106 |
107 | public static void skip(String message, boolean isScreeshotNeeded) {
108 | if (ConfigFactory.getConfig().skipped_steps_screenshot().trim().equalsIgnoreCase(YES) && isScreeshotNeeded) {
109 | ExtentManager.getExtentTest().skip(message,
110 | MediaEntityBuilder.createScreenCaptureFromBase64String(ScreenshotUtils.getBase64Image()).build());
111 | } else {
112 | skip(message);
113 | }
114 | }
115 |
116 | public static void skip(Markup message, boolean isScreeshotNeeded) {
117 | if (ConfigFactory.getConfig().skipped_steps_screenshot().trim().equalsIgnoreCase(YES) && isScreeshotNeeded) {
118 | ExtentManager.getExtentTest().skip(
119 | MediaEntityBuilder.createScreenCaptureFromBase64String(ScreenshotUtils.getBase64Image()).build());
120 | ExtentManager.getExtentTest().skip(message);
121 | } else {
122 | skip(message);
123 | }
124 | }
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/reports/ExtentManager.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.reports;
12 |
13 | import com.aventstack.extentreports.ExtentTest;
14 |
15 | //final -> We do not want any class to extend this class
16 | public final class ExtentManager {
17 |
18 | //private -> We do not want anyone to create the object of this class
19 | private ExtentManager() {
20 | }
21 |
22 | private static ThreadLocal extentTest = new ThreadLocal<>();
23 |
24 | //public static ExtentTest getExtentTest() {
25 | // return extentTest.get();
26 | // }
27 | // Now, the scope is default - Outside this package, No one will be able to access this
28 | // We do not want any Automation Tester to come and use methods like addAuthors(), addTags()
29 | static ExtentTest getExtentTest() {
30 | return extentTest.get();
31 | }
32 |
33 | static void setExtentTest(ExtentTest test) {
34 | extentTest.set(test);
35 | }
36 |
37 | static void unload() {
38 | extentTest.remove();
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/reports/ExtentReport.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.reports;
12 |
13 | import static com.learning.constants.FrameworkConstants.*;
14 |
15 | import java.util.Objects;
16 |
17 |
18 | import com.aventstack.extentreports.ExtentReports;
19 | import com.aventstack.extentreports.reporter.ExtentSparkReporter;
20 | import com.aventstack.extentreports.reporter.configuration.Theme;
21 | import com.learning.enums.AuthorType;
22 | import com.learning.enums.CategoryType;
23 | import com.learning.utils.BrowserInfoUtils;
24 | import com.learning.utils.IconUtils;
25 | import com.learning.utils.ReportUtils;
26 |
27 | //final -> We do not want any class to extend this class
28 | public final class ExtentReport {
29 |
30 | //private -> We do not want anyone to create the object of this class
31 | private ExtentReport() {
32 | }
33 |
34 | private static ExtentReports extent;
35 |
36 | public static void initReports() {
37 | if (Objects.isNull(extent)) {
38 | extent = new ExtentReports();
39 | ExtentSparkReporter spark = new ExtentSparkReporter(getExtentReportFilePath());
40 | /*
41 | * .viewConfigurer() .viewOrder() .as(new ViewName[] { ViewName.DASHBOARD,
42 | * ViewName.TEST, //ViewName.TAG, ViewName.CATEGORY, ViewName.AUTHOR,
43 | * ViewName.DEVICE, ViewName.EXCEPTION, ViewName.LOG }) .apply();
44 | */
45 |
46 | /*
47 | * You can even update the view of the ExtentRerport - What do you want to you
48 | * first, you can prioritize
49 | */
50 | /*
51 | * ExtentSparkReporter spark = new
52 | * ExtentSparkReporter(REPORTS_SPARK_CUSTOMISED_HTML).viewConfigurer().viewOrder
53 | * () .as(new ViewName[] { ViewName.DASHBOARD, ViewName.TEST, ViewName.CATEGORY
54 | * }).apply();
55 | */
56 | extent.attachReporter(spark);
57 |
58 | // spark.config().setEncoding("utf-8");
59 | spark.config().setTheme(Theme.STANDARD);
60 | spark.config().setDocumentTitle(PROJECT_NAME + " - ALL");
61 | spark.config().setReportName(PROJECT_NAME + " - ALL");
62 |
63 | extent.setSystemInfo("Organization", "Nagarro");
64 | extent.setSystemInfo("Employee",
65 | " Rajat Verma "
66 | + " " + ICON_SOCIAL_LINKEDIN + " " + ICON_SOCIAL_GITHUB);
67 | extent.setSystemInfo("Domain", "Engineering (IT - Software)" + " " + ICON_LAPTOP);
68 | extent.setSystemInfo("Skill", "Test Automation Engineer");
69 | }
70 | }
71 |
72 | public static void flushReports() {
73 | if (Objects.nonNull(extent)) {
74 | extent.flush();
75 | }
76 | ExtentManager.unload();
77 | ReportUtils.openReports();
78 | }
79 |
80 | public static void createTest(String testCaseName) {
81 | // ExtentManager.setExtentTest(extent.createTest(testCaseName));
82 | ExtentManager.setExtentTest(extent.createTest(IconUtils.getBrowserIcon() + " : " + testCaseName));
83 | }
84 |
85 | synchronized public static void addAuthors(AuthorType[] authors) {
86 | for (AuthorType author : authors) {
87 | ExtentManager.getExtentTest().assignAuthor(author.toString());
88 | }
89 | }
90 |
91 | // public static void addCategories(String[] categories) {
92 | synchronized public static void addCategories(CategoryType[] categories) {
93 | // for (String category : categories) {
94 | for (CategoryType category : categories) {
95 | ExtentManager.getExtentTest().assignCategory(category.toString());
96 | }
97 | }
98 |
99 | synchronized public static void addDevices() {
100 | ExtentManager.getExtentTest().assignDevice(BrowserInfoUtils.getBrowserInfo());
101 | // ExtentManager.getExtentTest()
102 | // .assignDevice(BrowserIconUtils.getBrowserIcon() + " : " + BrowserInfoUtils.getBrowserInfo());
103 | }
104 |
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/rough/ConfigLoaderUsingOwner.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.rough;
12 |
13 | import com.learning.config.FrameworkConfig;
14 | import org.aeonbits.owner.ConfigFactory;
15 |
16 | public class ConfigLoaderUsingOwner {
17 | public static void main(String[] args) {
18 |
19 | FrameworkConfig config = ConfigFactory.create(FrameworkConfig.class);
20 | System.out.println("config.timeout(): " + config.timeout());
21 | System.out.println("config.url(): " + config.url());
22 | System.out.println("config.browser() = " + config.browser());
23 | System.out.println("config.passed_steps_screenshot() = " + config.passed_steps_screenshot());
24 | System.out.println("config.skipped_steps_screenshot() = " + config.skipped_steps_screenshot());
25 | System.out.println("config.failed_steps_screenshot() = " + config.failed_steps_screenshot());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/rough/DataSupplierTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.rough;
12 |
13 | import io.github.sskorol.core.DataSupplier;
14 | import org.testng.annotations.Test;
15 |
16 | import java.util.Arrays;
17 | import java.util.List;
18 |
19 | //We are going to use this instead of DataProvider from TestNG
20 | public class DataSupplierTest {
21 |
22 | @Test(dataProvider = "getData")
23 | public void test1(String username){
24 | System.out.println("Username: "+username);
25 | }
26 |
27 | //@DataProvider --> Return type -> Object[][] or Object[]
28 | @DataSupplier //--> It can read any file (CSV, xlsx, JSON, YAMLDataSupplierTest)
29 | public List getData(){
30 | return Arrays.asList("Selenium","Appium","RestAssured");
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/rough/JavaFakerAPI.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.rough;
12 |
13 | import com.github.javafaker.Faker;
14 |
15 | public class JavaFakerAPI {
16 | public static void main(String[] args) {
17 |
18 | Faker faker = new Faker();
19 | for (int i = 0; i < 2; i++) {
20 | System.out.println("---------------------");
21 | System.out.println("faker.address().cityName() = " + faker.address().cityName());
22 | System.out.println("faker.superhero().name() = " + faker.superhero().name());
23 | System.out.println("faker.address().fullAddress() = " + faker.address().fullAddress());
24 | System.out.println("faker.animal().name() = " + faker.animal().name());
25 | System.out.println("faker.number().randomNumber() = " + faker.number().randomNumber());
26 | faker.number().numberBetween(5,500);
27 | }
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/rough/datasupplier_excel/DataSupplierTest_Excel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.rough.datasupplier_excel;
12 |
13 | import com.learning.testdata.TestData;
14 | import io.github.sskorol.core.DataSupplier;
15 | import io.github.sskorol.data.TestDataReader;
16 | import io.github.sskorol.data.XlsxReader;
17 | import one.util.streamex.StreamEx;
18 | import org.testng.annotations.Test;
19 |
20 | //We are going to use this instead of DataProvider from TestNG
21 | public class DataSupplierTest_Excel {
22 |
23 | @Test(dataProvider = "getData")
24 | public void test1(TestData_Rough testData_rough) {
25 | System.out.println("testData.testCaseCame = " + testData_rough.testCaseCame);
26 | System.out.println("testData.username = " + testData_rough.username);
27 | System.out.println("testData.password = " + testData_rough.password);
28 | System.out.println("testData.age = " + testData_rough.age);
29 |
30 | }
31 | //@DataProvider --> Return type -> Object[][] or Object[]
32 | @DataSupplier //--> It can read any file (CSV, xlsx, JSON, YAMLDataSupplierTest)
33 | public StreamEx getData() {
34 |
35 | // return Arrays.asList("Selenium", "Appium", "RestAssured");
36 |
37 | return TestDataReader.use(XlsxReader.class)
38 | .withTarget(TestData_Rough.class)
39 | //By default, it looks for files in src/test/resources directory
40 | .withSource("testdata/testData_rough.xlsx")
41 | .read();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/rough/datasupplier_excel/DataSupplierTest_Excel2.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.rough.datasupplier_excel;
12 |
13 | import com.learning.testdata.TestData;
14 | import io.github.sskorol.core.DataSupplier;
15 | import io.github.sskorol.data.TestDataReader;
16 | import io.github.sskorol.data.XlsxReader;
17 | import one.util.streamex.StreamEx;
18 | import org.testng.annotations.Test;
19 |
20 | //We are going to use this instead of DataProvider from TestNG
21 | public class DataSupplierTest_Excel2 {
22 |
23 | @Test(dataProvider = "getData")
24 | public void test1(TestData testData) {
25 | System.out.println("-----------------------------");
26 | System.out.println("testData.testCaseName = " + testData.getTestCaseName());
27 | System.out.println("testData.username = " + testData.getUsername());
28 | System.out.println("testData.password = " + testData.getPassword());
29 | System.out.println("testData.expectedTitle = " + testData.getExpectedTitle());
30 | System.out.println("testData.expectedError = " + testData.getExpectedError());
31 | }
32 | //@DataProvider --> Return type -> Object[][] or Object[]
33 | @DataSupplier //--> It can read any file (CSV, xlsx, JSON, YAMLDataSupplierTest)
34 | public StreamEx getData() {
35 |
36 | return TestDataReader.use(XlsxReader.class)
37 | .withTarget(TestData.class)
38 | //By default, it looks for files in src/test/resources directory
39 | .withSource("testdata/testData.xlsx")
40 | .read();
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/rough/datasupplier_excel/TestData_Rough.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.rough.datasupplier_excel;
12 |
13 | import com.beust.jcommander.converters.IntegerConverter;
14 | import com.creditdatamw.zerocell.annotation.Column;
15 |
16 | public class TestData_Rough {
17 |
18 | // @Column(name="testcasename",index = 0) ->
19 | //Column name is testcasename and it is at 0th index in Excel sheet
20 | @Column(name="testcasename",index = 0)
21 | public String testCaseCame;
22 |
23 | @Column(name="username",index = 1)
24 | public String username;
25 |
26 | @Column(name="password",index = 2)
27 | public String password;
28 |
29 | //converterClass = IntegerConverter.class -> This will do the conversion from String to int
30 | @Column(name="age",index = 3, converterClass = IntegerConverter.class)
31 | public int age;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/testdata/TestData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.testdata;
12 |
13 | import com.beust.jcommander.converters.IntegerConverter;
14 | import com.creditdatamw.zerocell.annotation.Column;
15 |
16 | public class TestData {
17 |
18 | // @Column(name="Test Case Name",index = 0) ->
19 | //Column name is Test Case Name and it is at 0th index in Excel sheet
20 | @Column(name = "Test Case Name", index = 0)
21 | private String testCaseName;
22 |
23 | @Column(name = "Username", index = 1)
24 | private String username;
25 |
26 | @Column(name = "Password", index = 2)
27 | private String password;
28 |
29 | @Column(name = "Expected Title", index = 3)
30 | private String expectedTitle;
31 |
32 | @Column(name = "Expected Error", index = 4)
33 | private String expectedError;
34 |
35 | @Column(name = "Expected URL", index = 5)
36 | private String expectedUrl;
37 |
38 |
39 | // converterClass = IntegerConverter.class -> This will do the conversion from String to int
40 | // @Column(name="age",index = 3, converterClass = IntegerConverter.class)
41 | //public int age;
42 |
43 |
44 | public String getTestCaseName() {
45 | return testCaseName;
46 | }
47 |
48 | public String getUsername() {
49 | return username;
50 | }
51 |
52 | public String getPassword() {
53 | return password;
54 | }
55 |
56 | public String getExpectedTitle() {
57 | return expectedTitle;
58 | }
59 |
60 | public String getExpectedError() {
61 | return expectedError;
62 | }
63 |
64 | public String getExpectedUrl() {
65 | return expectedUrl;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/BrowserInfoUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import com.learning.driver.DriverManager;
14 | import org.openqa.selenium.Capabilities;
15 | import org.openqa.selenium.remote.RemoteWebDriver;
16 |
17 | //final -> We do not want any class to extend this class
18 | public final class BrowserInfoUtils {
19 |
20 | //private -> We do not want anyone to create the object of this class
21 | //Private constructor to avoid external instantiation
22 | private BrowserInfoUtils() {
23 | }
24 |
25 | public static String getBrowserInfo() {
26 | Capabilities capabilities = ((RemoteWebDriver) DriverManager.getDriver()).getCapabilities();
27 | return capabilities.getBrowserName().toUpperCase();
28 |
29 | }
30 |
31 | public static String getBrowserVersionInfo() {
32 | Capabilities capabilities = ((RemoteWebDriver) DriverManager.getDriver()).getCapabilities();
33 | return capabilities.getVersion();
34 |
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/BrowserOSInfoUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | //final -> We do not want any class to extend this class
14 | public final class BrowserOSInfoUtils {
15 |
16 | //private -> We do not want anyone to create the object of this class
17 | // Private constructor to avoid external instantiation
18 | private BrowserOSInfoUtils() {
19 | }
20 |
21 | public static String getOS_Browser_BrowserVersionInfo() {
22 | return OSInfoUtils.getOSInfo() + " & " + BrowserInfoUtils.getBrowserInfo() + " - "
23 | + BrowserInfoUtils.getBrowserVersionInfo();
24 |
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/DataProviderUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import com.learning.testdata.TestData;
14 | import io.github.sskorol.core.DataSupplier;
15 | import io.github.sskorol.data.TestDataReader;
16 | import io.github.sskorol.data.XlsxReader;
17 | import one.util.streamex.StreamEx;
18 |
19 | import java.lang.reflect.Method;
20 |
21 | import static com.learning.constants.FrameworkConstants.TEST_DATA_XLSX_FILE;
22 |
23 | public class DataProviderUtils {
24 |
25 |
26 | //@DataProvider --> Return type -> Object[][] or Object[]
27 | //@DataSupplier //--> It can read any file (CSV, xlsx, JSON, YAMLDataSupplierTest)
28 | //@DataSupplier(runInParallel = true)
29 | @DataSupplier(runInParallel = true,name="getTestData")
30 | public StreamEx getData(Method method) {
31 |
32 | return TestDataReader.use(XlsxReader.class)
33 | .withTarget(TestData.class)
34 | //By default, it looks for files in src/test/resources directory
35 | .withSource(TEST_DATA_XLSX_FILE)
36 | .read()
37 | // .filter(testData -> testData.getTestCaseName().equalsIgnoreCase("titleValidationTest"));
38 |
39 | // Using Java reflection -> Getting method name and use it for filtering
40 | .filter(testData -> testData.getTestCaseName().equalsIgnoreCase(method.getName()));
41 | }
42 |
43 |
44 | //@DataProvider(name = "getInvalidLoginData")
45 | public static Object[][] REFERENCE_getInvalidLoginData() {
46 | return new Object[][]{
47 | //Username, Password, Expected Error Message
48 | {"Admin", "admin1234", "Invalid credentials"}
49 | };
50 | }
51 |
52 | //@DataProvider(name = "getValidLoginData")
53 | public static Object[][] REFERENCE_getValidLoginData() {
54 | return new Object[][]{
55 | //Username, Password, Expected Page Title
56 | {"Admin", "admin123", "OrangeHRM"}
57 | };
58 | }
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/DateUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import java.util.Date;
14 |
15 | //final -> We do not want any class to extend this class
16 | public final class DateUtils {
17 |
18 | //private -> We do not want anyone to create the object of this class
19 | // Private constructor to avoid external instantiation
20 | private DateUtils() {
21 | }
22 |
23 | public static String getCurrentDate() {
24 | Date date = new Date();
25 | return date.toString().replace(":", "_").replace(" ", "_");
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/EmailSendUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import static com.learning.constants.FrameworkConstants.PROJECT_NAME;
14 | import static com.learning.constants.FrameworkConstants.YES;
15 | import static com.learning.java_Mail_API.EmailConfig.*;
16 |
17 | import javax.mail.MessagingException;
18 |
19 | import com.learning.config.ConfigFactory;
20 | import com.learning.constants.FrameworkConstants;
21 | import com.learning.java_Mail_API.EmailAttachmentsSender;
22 |
23 | public class EmailSendUtils {
24 |
25 | /**
26 | * sendEmail_WithAttachmentsAndFormattedBodyText_ToManyUsersRajat
27 | */
28 | public static void sendEmail(int count_totalTCs, int count_passedTCs, int count_failedTCs, int count_skippedTCs) {
29 |
30 | if(ConfigFactory.getConfig().send_email_to_users().trim().equalsIgnoreCase(YES)){
31 | System.out.println("****************************************");
32 | System.out.println("Send Email - START");
33 | System.out.println("****************************************");
34 |
35 | // System.out.println("File name: " + FrameworkConstants.getExtentReportPath());
36 | System.out.println("File name: " + FrameworkConstants.getExtentReportFilePath());
37 |
38 |
39 | String messageBody = getTestCasesCountInFormat(count_totalTCs, count_passedTCs, count_failedTCs,
40 | count_skippedTCs);
41 | System.out.println(messageBody);
42 |
43 | /*
44 | * String attachmentFile_ExtentReport = Constants.REPORTS_Folder +
45 | * "All_Automation_Report_Fri_Sep_10_03_47_17_IST_2021.html";
46 | */
47 |
48 | // String attachmentFile_ExtentReport = FrameworkConstants.getExtentReportPath();
49 | String attachmentFile_ExtentReport = FrameworkConstants.getExtentReportFilePath();
50 |
51 |
52 | try {
53 | EmailAttachmentsSender.sendEmailWithAttachments(SERVER, PORT, FROM, PASSWORD, TO, SUBJECT, messageBody,
54 | attachmentFile_ExtentReport);
55 |
56 | System.out.println("****************************************");
57 | System.out.println("Email sent successfully.");
58 | System.out.println("Send Email - END");
59 | System.out.println("****************************************");
60 | } catch (MessagingException e) {
61 | e.printStackTrace();
62 | }
63 |
64 | }
65 |
66 | }
67 |
68 | private static String getTestCasesCountInFormat(int count_totalTCs, int count_passedTCs, int count_failedTCs,
69 | int count_skippedTCs) {
70 | System.out.println("count_totalTCs: " + count_totalTCs);
71 | System.out.println("count_passedTCs: " + count_passedTCs);
72 | System.out.println("count_failedTCs: " + count_failedTCs);
73 | System.out.println("count_skippedTCs: " + count_skippedTCs);
74 |
75 | return "\r\n" + "\r\n" + " \r\n" + "\r\n"
76 | + " \r\n\r\n"
77 | + PROJECT_NAME + " |
\r\n\r\n\r\n"
78 | + " \r\n"
79 | + " "
80 | + count_totalTCs + " | \r\n"
81 | + " Total | \r\n" + " \r\n"
82 | + " \r\n" + " | \r\n" + " \r\n"
83 | + " \r\n" + " \r\n"
84 | + " "
85 | + count_passedTCs + " | \r\n"
86 | + " Passed | \r\n" + " \r\n"
87 | + " \r\n" + " | \r\n" + " \r\n"
88 | + " \r\n"
89 | + " "
90 | + count_failedTCs + " | \r\n"
91 | + " Failed | \r\n" + " \r\n"
92 | + " \r\n" + " \r\n" + " | \r\n"
93 | + " \r\n" + " \r\n"
94 | + " "
95 | + count_skippedTCs + " | \r\n"
96 | + " Skipped | \r\n" + " \r\n"
97 | + " \r\n" + " \r\n" + " | \r\n"
98 | + "
\r\n" + " \r\n" + " \r\n"
99 | + "
\r\n" + " \r\n" + " \r\n" + "";
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/IconUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import static com.learning.constants.FrameworkConstants.*;
14 |
15 | //final -> We do not want any class to extend this class
16 | public final class IconUtils {
17 |
18 | /**
19 | * Private constructor to avoid external instantiation
20 | */
21 | //private -> We do not want anyone to create the object of this class
22 | private IconUtils() {
23 | }
24 |
25 | public static String getBrowserIcon() {
26 | String browserInLowerCase = BrowserInfoUtils.getBrowserInfo().toLowerCase();
27 | if (browserInLowerCase.contains(ICON_BROWSER_EDGE)) {
28 | return ICON_BROWSER_PREFIX + ICON_BROWSER_EDGE + ICON_BROWSER_SUFFIX;
29 | } else {
30 | return ICON_BROWSER_PREFIX + browserInLowerCase + ICON_BROWSER_SUFFIX;
31 | }
32 | }
33 |
34 | public static String getOSIcon() {
35 |
36 | String operSys = OSInfoUtils.getOSInfo().toLowerCase();
37 | if (operSys.contains("win")) {
38 | return ICON_OS_WINDOWS;
39 | } else if (operSys.contains("nix") || operSys.contains("nux") || operSys.contains("aix")) {
40 | return ICON_OS_LINUX;
41 | } else if (operSys.contains("mac")) {
42 | return ICON_OS_MAC;
43 | }
44 | return operSys;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/OSInfoUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | //final -> We do not want any class to extend this class
14 | public final class OSInfoUtils {
15 |
16 | /**
17 | * Private constructor to avoid external instantiation
18 | */
19 | //private -> We do not want anyone to create the object of this class
20 | private OSInfoUtils() {
21 | }
22 |
23 | public static String getOSInfo() {
24 | return System.getProperty("os.name").replace(" ", "_");
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/ReportUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import com.learning.config.ConfigFactory;
14 | import com.learning.exceptions.FrameworkException;
15 | import com.learning.exceptions.InvalidPathForExtentReportFileException;
16 |
17 | import java.awt.*;
18 | import java.io.File;
19 | import java.io.FileNotFoundException;
20 | import java.io.IOException;
21 |
22 | import static com.learning.constants.FrameworkConstants.*;
23 |
24 |
25 | //final -> We do not want any class to extend this class
26 | public final class ReportUtils {
27 |
28 | //private -> We do not want anyone to create the object of this class
29 | // Private constructor to avoid external instantiation
30 | private ReportUtils() {
31 | }
32 |
33 | public static String createExtentReportPath() {
34 | if (ConfigFactory.getConfig().override_reports().trim().equalsIgnoreCase(NO)) {
35 | /**
36 | * Report name ->
37 | *
38 | * Windows_10_Tue_Oct_05_02_30_46_IST_2021_AutomationReport.html
39 | * Mac_OS_X_Tue_Feb_22_17_09_05_IST_2022_AutomationReport.html
40 | */
41 | return EXTENT_REPORT_FOLDER_PATH + OSInfoUtils.getOSInfo() + "_" + DateUtils.getCurrentDate() + "_"
42 | + EXTENT_REPORT_NAME;
43 |
44 | } else {
45 | return EXTENT_REPORT_FOLDER_PATH + EXTENT_REPORT_NAME;
46 | }
47 | }
48 |
49 | public static void openReports() {
50 | if (ConfigFactory.getConfig().open_reports_after_execution().trim().equalsIgnoreCase(YES)) {
51 | try {
52 | Desktop.getDesktop().browse(new File(getExtentReportFilePath()).toURI());
53 | } catch (FileNotFoundException fileNotFoundException) {
54 | throw new InvalidPathForExtentReportFileException("Extent Report file you are trying to reach is not found", fileNotFoundException.fillInStackTrace());
55 | } catch (IOException ioException) {
56 | throw new FrameworkException("Extent Report file you are trying to reach got IOException while reading the file", ioException.fillInStackTrace());
57 | }
58 |
59 |
60 | }
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/ScreenshotUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import com.learning.driver.DriverManager;
14 | import org.openqa.selenium.OutputType;
15 | import org.openqa.selenium.TakesScreenshot;
16 |
17 | //final -> We do not want any class to extend this class
18 | public final class ScreenshotUtils {
19 |
20 | //private -> We do not want anyone to create the object of this class
21 | private ScreenshotUtils() {
22 | }
23 |
24 | public static String getBase64Image() {
25 | return ((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BASE64);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/SeleniumUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import com.google.common.util.concurrent.Uninterruptibles;
14 | import com.learning.config.ConfigFactory;
15 | import com.learning.driver.DriverManager;
16 | import com.learning.enums.WaitType;
17 | import com.learning.reports.ExtentLogger;
18 | import org.openqa.selenium.By;
19 | import org.openqa.selenium.WebElement;
20 | import org.openqa.selenium.support.ui.ExpectedConditions;
21 | import org.openqa.selenium.support.ui.WebDriverWait;
22 |
23 | import java.util.concurrent.TimeUnit;
24 |
25 | import static com.learning.constants.FrameworkConstants.*;
26 |
27 | public class SeleniumUtils {
28 |
29 | private static WebElement waitUntilPresenceOfElementLocated(By by) {
30 | WebDriverWait wait = new WebDriverWait(DriverManager.getDriver(), ConfigFactory.getConfig().timeout());
31 | return wait.until(ExpectedConditions.presenceOfElementLocated(by));
32 | }
33 |
34 | private static WebElement waitUntilElementToBeClickable(By by) {
35 | WebDriverWait wait = new WebDriverWait(DriverManager.getDriver(), ConfigFactory.getConfig().timeout());
36 | return wait.until(ExpectedConditions.elementToBeClickable(by));
37 | }
38 |
39 | private static WebElement waitUntilElementToBeVisible(By by) {
40 | WebDriverWait wait = new WebDriverWait(DriverManager.getDriver(), ConfigFactory.getConfig().timeout());
41 | return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
42 | }
43 |
44 | public static void sendKeys(By by, String value) {
45 | // WebDriverWait wait = new WebDriverWait(DriverManager.getDriver(), ConfigFactory.getConfig().timeout());
46 | // wait.until(ExpectedConditions.presenceOfElementLocated(by));
47 | // return DriverManager.getDriver().findElement(by).getText();
48 | WebElement element = waitUntilPresenceOfElementLocated(by);
49 | element.sendKeys(value);
50 | // ExtentLogger.pass("Value: " + value + " is successfully passed in textBox: " + element.getText());
51 | ExtentLogger.pass("Value: " + value + " is successfully passed in textBox: " + element.getText(), true);
52 | }
53 |
54 | public static void sendKeys(By by, String value, String elementName) {
55 | // WebDriverWait wait = new WebDriverWait(DriverManager.getDriver(), ConfigFactory.getConfig().timeout());
56 | // wait.until(ExpectedConditions.presenceOfElementLocated(by));
57 | // return DriverManager.getDriver().findElement(by).getText();
58 | WebElement element = waitUntilPresenceOfElementLocated(by);
59 | element.sendKeys(value);
60 | // ExtentLogger.pass("Value " + BOLD_START + value + BOLD_END + " is successfully passed in "
61 | // + BOLD_START + elementName + BOLD_END + " textbox.");
62 | ExtentLogger.pass("Value " + BOLD_START + value + BOLD_END + " is successfully passed in "
63 | + BOLD_START + elementName + BOLD_END + " textbox.", true);
64 | }
65 |
66 |
67 | public static void click(By by) {
68 | // WebDriverWait wait = new WebDriverWait(DriverManager.getDriver(), ConfigFactory.getConfig().timeout());
69 | // wait.until(ExpectedConditions.elementToBeClickable(by));
70 | // DriverManager.getDriver().findElement(by).click();
71 | WebElement element = waitUntilElementToBeClickable(by);
72 | element.click();
73 | // ExtentLogger.pass("Element: " + element.getText() + " is clicked successfully.");
74 | //ExtentLogger.pass(element.getText() + " is clicked successfully.", true);
75 | ExtentLogger.pass("Clicking on: " + BOLD_START + element.getText() + BOLD_END, true);
76 |
77 | }
78 |
79 | public static void click(By by, WaitType waitType) {
80 | WebElement element = getElementAfterWait(by, waitType);
81 | // ExtentLogger.pass("Element: " + BOLD_START + element.getText() + BOLD_END + " is clicked successfully");
82 | // ExtentLogger.pass(BOLD_START + element.getText() + BOLD_END + " is clicked successfully", true);
83 | ExtentLogger.pass("Clicking on: " + BOLD_START + element.getText() + BOLD_END, true);
84 | element.click();
85 |
86 | }
87 |
88 | private static WebElement getElementAfterWait(By by, WaitType waitType) {
89 | //waitUntilElementToBeClickable(by).click();
90 | WebElement element = null;
91 | if (waitType == WaitType.PRESENCE) {
92 | element = waitUntilPresenceOfElementLocated(by);
93 | } else if (waitType == WaitType.CLICKABLE) {
94 | element = waitUntilElementToBeClickable(by);
95 | } else if (waitType == WaitType.VISIBLE) {
96 | element = waitUntilElementToBeVisible(by);
97 | }
98 | return element;
99 | }
100 |
101 | public static void click(By by, WaitType waitType, String elementName) {
102 | WebElement element = getElementAfterWait(by, waitType);
103 | // ExtentLogger.pass("Element: " + BOLD_START + elementName + BOLD_END + " is clicked successfully.");
104 | //ExtentLogger.pass(BOLD_START + elementName + BOLD_END + " is clicked successfully.", true);
105 | ExtentLogger.pass("Clicking on: " + BOLD_START + elementName + BOLD_END, true);
106 | element.click();
107 |
108 | }
109 |
110 |
111 | public static String getElementText(By by) {
112 | // WebDriverWait wait = new WebDriverWait(DriverManager.getDriver(), ConfigFactory.getConfig().timeout());
113 | // wait.until(ExpectedConditions.presenceOfElementLocated(by));
114 | // return DriverManager.getDriver().findElement(by).getText();
115 | WebElement element = waitUntilPresenceOfElementLocated(by);
116 | ExtentLogger.info("Element Text: " + BOLD_START + element.getText() + BOLD_END);
117 | return element.getText();
118 | }
119 |
120 | public static String getPageTitle() {
121 | String title = DriverManager.getDriver().getTitle();
122 | ExtentLogger.info("Page title: " + BOLD_START + title + BOLD_END);
123 | return title;
124 | }
125 |
126 |
127 | public static WebElement getElement(By by) {
128 | return waitUntilElementToBeVisible(by);
129 | }
130 |
131 | public static void captureScreenshot() {
132 | ExtentLogger.captureScreenshot();
133 | }
134 |
135 | public static void waitForSomeTime() {
136 | Uninterruptibles.sleepUninterruptibly(WAIT, TimeUnit.SECONDS);
137 | }
138 |
139 | public static void waitForGivenTime(long time) {
140 | Uninterruptibles.sleepUninterruptibly(time, TimeUnit.SECONDS);
141 | }
142 |
143 | public static String getWebPageURL() {
144 | String url = DriverManager.getDriver().getCurrentUrl();
145 | //ExtentLogger.info("Page URL: " + BOLD_START + url + BOLD_END);
146 | ExtentLogger.info("Page URL: " + "" + url + "");
147 |
148 | return url;
149 | }
150 |
151 | }
152 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/VerificationUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import com.learning.reports.ExtentLogger;
14 | import org.testng.Assert;
15 |
16 |
17 | //final -> We do not want any class to extend this class
18 | public final class VerificationUtils {
19 |
20 | //private -> We do not want anyone to create the object of this class
21 | private VerificationUtils() {
22 | }
23 |
24 | public static void validateResponse(Object actual, Object expected, String message) {
25 | try {
26 | Assert.assertEquals(actual, expected, message);
27 | ExtentLogger.pass(
28 | message + " | Actual: " + actual + ", Expected: " + expected);
29 | } catch (AssertionError assertionError) {
30 | ExtentLogger.fail(
31 | message + " | Actual: " + actual + ", Expected: " + expected);
32 | Assert.fail(message);
33 | }
34 | }
35 |
36 | public static void validateResponse(boolean result, String message) {
37 | try {
38 | Assert.assertTrue(result);
39 | ExtentLogger.pass("" + message + "");
40 | // report.info("PASS : " + message);
41 | } catch (AssertionError assertionError) {
42 | // report.error("FAIL : " + message);
43 | ExtentLogger.fail("" + message + "");
44 | Assert.fail(message);
45 | }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/learning/utils/ZipUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.utils;
12 |
13 | import java.io.File;
14 |
15 | import org.zeroturnaround.zip.ZipUtil;
16 |
17 | import static com.learning.constants.FrameworkConstants.*;
18 |
19 | public class ZipUtils {
20 |
21 | /* make Zip file of Extent Reports in Project Root folder */
22 | public static void zip() {
23 | // ZipUtil.pack(new File(REPORT_LOCATION),
24 | // new File(Zipped_ExtentReports_Folder_Name));
25 |
26 | ZipUtil.pack(new File(EXTENT_REPORT_FOLDER_PATH),
27 | new File(Zipped_ExtentReports_Folder_Name));
28 |
29 | System.out.println("Zipped ExtentReports folder successfuly");
30 | }
31 |
32 | /*public static void main(String[] args) {
33 | System.out.println("REPORT_LOCATION = " + REPORT_LOCATION);
34 | System.out.println("Zipped_ExtentReports_Folder_Name = " + Zipped_ExtentReports_Folder_Name);
35 |
36 | ZipUtil.pack(new File(REPORT_LOCATION),
37 | new File(Zipped_ExtentReports_Folder_Name));
38 | System.out.println("Zipped ExtentReports folder successfuly");
39 | }*/
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/TMB_SeleniumFramework2/99452e2b553199c1dcf6a24dfbc06ae16fcc5771/src/test/.DS_Store
--------------------------------------------------------------------------------
/src/test/java/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/TMB_SeleniumFramework2/99452e2b553199c1dcf6a24dfbc06ae16fcc5771/src/test/java/.DS_Store
--------------------------------------------------------------------------------
/src/test/java/com/learning/tests/BaseTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.tests;
12 |
13 | import com.learning.driver.Driver;
14 | import org.testng.annotations.AfterMethod;
15 | import org.testng.annotations.BeforeMethod;
16 |
17 | public class BaseTest {
18 |
19 | @BeforeMethod
20 | public void beforeMethod() {
21 | Driver.initDriver();
22 | }
23 |
24 | @AfterMethod
25 | public void afterMethod() {
26 | Driver.quitDriver();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/com/learning/tests/DashboardApplyLeaveTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.tests;
12 |
13 | import com.learning.annotations.FrameworkAnnotation;
14 | import com.learning.driver.DriverManager;
15 | import com.learning.enums.AuthorType;
16 | import com.learning.enums.CategoryType;
17 | import com.learning.pages.HomePage;
18 | import com.learning.pages.LoginPage;
19 | import com.learning.testdata.TestData;
20 | import com.learning.utils.DataProviderUtils;
21 | import com.learning.utils.VerificationUtils;
22 | import org.openqa.selenium.By;
23 | import org.testng.Assert;
24 | import org.testng.annotations.Test;
25 |
26 | import static com.learning.constants.FrameworkConstants.ASSERTION_FOR;
27 |
28 | public class DashboardApplyLeaveTest extends BaseTest {
29 |
30 | @FrameworkAnnotation(author = { AuthorType.NISHANT},
31 | category = {CategoryType.SMOKE, CategoryType.REGRESSION})
32 | @Test(groups = {"SMOKE","REGRESSION"},description = "To check whether the User can not login with Invalid Credentials",
33 | dataProvider = "getTestData", dataProviderClass = DataProviderUtils.class)
34 | public void dashboardApplyLeaveTest(TestData testData) {
35 |
36 | LoginPage loginPage = new LoginPage();
37 | HomePage homePage = loginPage.loginToApplication(testData.getUsername(), testData.getPassword());
38 |
39 | homePage.clickOnApplyLeave();
40 |
41 | // Assert.assertTrue(homePage.getPageURL().contains(testData.getExpectedUrl()),
42 | // "Assertion for Apply Leave URL");
43 |
44 | VerificationUtils.validateResponse(homePage.getPageURL().contains(testData.getExpectedUrl()+"_FAIL"),
45 | ASSERTION_FOR +" - Apply Leave URL ");
46 | }
47 |
48 |
49 | /**
50 | * --------------------------------------------------------------------- (2nd time)
51 | */
52 | // @FrameworkAnnotation(author = { AuthorType.RAJAT, AuthorType.NISHANT},
53 | // category = { CategoryType.BVT,CategoryType.REGRESSION })
54 | // @Test(description = "To check whether the User can not login with Invalid Credentials",
55 | // dataProvider = "getInvalidLoginData",dataProviderClass = DataProviderUtils.class)
56 | public void REFERENCE_errorInvalidCredentials(String username, String password, String expectedError) {
57 |
58 | LoginPage loginPage = new LoginPage();
59 | // loginPage.setUsername("Admin");
60 | // loginPage.setPassword("admin1234");
61 | // loginPage.setUsername(username);
62 | // loginPage.setPassword(password);
63 | // loginPage.clickLogin();
64 |
65 | // Method Chaining
66 | // loginPage
67 | // .setUsername(username)
68 | // .setPassword(password)
69 | // .clickLogin();
70 | loginPage.loginToApplication(username, password);
71 |
72 | String errorInvalidCreds = DriverManager.getDriver().findElement(By.id("spanMessage")).getText();
73 | Assert.assertEquals(errorInvalidCreds, expectedError,
74 | "Assertion for Invalid credentials Error message");
75 | }
76 |
77 |
78 | /**
79 | * --------------------------------------------------------------------- (1st time)
80 | */
81 |
82 | // @Test(description = "To check whether the User can not login with Invalid Credentials")
83 | public void REFERENCE__errorInvalidCredentials() {
84 | // driver.findElement(By.id("txtUsername")).sendKeys("Admin");
85 | // driver.findElement(By.id("txtPassword")).sendKeys("admin1234");
86 | // driver.findElement(By.id("btnLogin")).click();
87 | // holdScript(3);
88 |
89 | // Driver.threadLocal.get().findElement(By.id("txtUsername")).sendKeys("Admin");
90 | // Driver.threadLocal.get().findElement(By.id("txtPassword")).sendKeys("admin1234");
91 | // Driver.threadLocal.get().findElement(By.id("btnLogin")).click();
92 |
93 | // DriverManager.getDriver().findElement(By.id("txtUsername")).sendKeys("Admin");
94 | // DriverManager.getDriver().findElement(By.id("txtPassword")).sendKeys("admin1234");
95 | // DriverManager.getDriver().findElement(By.id("btnLogin")).click();
96 |
97 | // LoginPage loginPage =new LoginPage();
98 | // loginPage.setUsername("Admin");
99 | // loginPage.setPassword("admin1234");
100 | // loginPage.clickLogin();
101 |
102 | // String errorInvalidCreds = Driver.driver.findElement(By.id("spanMessage")).getText();
103 | // String errorInvalidCreds = Driver.threadLocal.get().findElement(By.id("spanMessage")).getText();
104 | String errorInvalidCreds = DriverManager.getDriver().findElement(By.id("spanMessage")).getText();
105 |
106 |
107 | // Assert.assertEquals(errorInvalidCreds, "Invalid credentials",
108 | // "Assertion for Invalid credentials Error message");
109 | Assert.assertEquals(errorInvalidCreds, "无效的凭证",
110 | "Assertion for Invalid credentials Error message");
111 |
112 |
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/src/test/java/com/learning/tests/DashboardMyTimesheetTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.tests;
12 |
13 | import com.learning.annotations.FrameworkAnnotation;
14 | import com.learning.driver.DriverManager;
15 | import com.learning.enums.AuthorType;
16 | import com.learning.enums.CategoryType;
17 | import com.learning.pages.HomePage;
18 | import com.learning.pages.LoginPage;
19 | import com.learning.testdata.TestData;
20 | import com.learning.utils.DataProviderUtils;
21 | import com.learning.utils.VerificationUtils;
22 | import org.openqa.selenium.By;
23 | import org.testng.Assert;
24 | import org.testng.annotations.Test;
25 |
26 | import static com.learning.constants.FrameworkConstants.ASSERTION_FOR;
27 |
28 | public class DashboardMyTimesheetTest extends BaseTest {
29 |
30 | @FrameworkAnnotation(author = { AuthorType.NISHANT},
31 | category = {CategoryType.SMOKE, CategoryType.REGRESSION})
32 | @Test(groups = {"SMOKE","REGRESSION"},description = "To check whether the User can not login with Invalid Credentials",
33 | dataProvider = "getTestData", dataProviderClass = DataProviderUtils.class)
34 | public void dashboardMyTimesheetTest(TestData testData) {
35 |
36 | LoginPage loginPage = new LoginPage();
37 | HomePage homePage = loginPage.loginToApplication(testData.getUsername(), testData.getPassword());
38 |
39 | homePage.clickOnMyTimeSheet();
40 |
41 | // Assert.assertTrue(homePage.getPageURL().contains(testData.getExpectedUrl()),
42 | // "Assertion for My TimeSheet URL");
43 | VerificationUtils.validateResponse(homePage.getPageURL().contains(testData.getExpectedUrl()),
44 | ASSERTION_FOR +" - My TimeSheet URL ");
45 | }
46 |
47 |
48 | /**
49 | * --------------------------------------------------------------------- (2nd time)
50 | */
51 | // @FrameworkAnnotation(author = { AuthorType.RAJAT, AuthorType.NISHANT},
52 | // category = { CategoryType.BVT,CategoryType.REGRESSION })
53 | // @Test(description = "To check whether the User can not login with Invalid Credentials",
54 | // dataProvider = "getInvalidLoginData",dataProviderClass = DataProviderUtils.class)
55 | public void REFERENCE_errorInvalidCredentials(String username, String password, String expectedError) {
56 |
57 | LoginPage loginPage = new LoginPage();
58 | // loginPage.setUsername("Admin");
59 | // loginPage.setPassword("admin1234");
60 | // loginPage.setUsername(username);
61 | // loginPage.setPassword(password);
62 | // loginPage.clickLogin();
63 |
64 | // Method Chaining
65 | // loginPage
66 | // .setUsername(username)
67 | // .setPassword(password)
68 | // .clickLogin();
69 | loginPage.loginToApplication(username, password);
70 |
71 | String errorInvalidCreds = DriverManager.getDriver().findElement(By.id("spanMessage")).getText();
72 | Assert.assertEquals(errorInvalidCreds, expectedError,
73 | "Assertion for Invalid credentials Error message");
74 | }
75 |
76 |
77 | /**
78 | * --------------------------------------------------------------------- (1st time)
79 | */
80 |
81 | // @Test(description = "To check whether the User can not login with Invalid Credentials")
82 | public void REFERENCE__errorInvalidCredentials() {
83 | // driver.findElement(By.id("txtUsername")).sendKeys("Admin");
84 | // driver.findElement(By.id("txtPassword")).sendKeys("admin1234");
85 | // driver.findElement(By.id("btnLogin")).click();
86 | // holdScript(3);
87 |
88 | // Driver.threadLocal.get().findElement(By.id("txtUsername")).sendKeys("Admin");
89 | // Driver.threadLocal.get().findElement(By.id("txtPassword")).sendKeys("admin1234");
90 | // Driver.threadLocal.get().findElement(By.id("btnLogin")).click();
91 |
92 | // DriverManager.getDriver().findElement(By.id("txtUsername")).sendKeys("Admin");
93 | // DriverManager.getDriver().findElement(By.id("txtPassword")).sendKeys("admin1234");
94 | // DriverManager.getDriver().findElement(By.id("btnLogin")).click();
95 |
96 | // LoginPage loginPage =new LoginPage();
97 | // loginPage.setUsername("Admin");
98 | // loginPage.setPassword("admin1234");
99 | // loginPage.clickLogin();
100 |
101 | // String errorInvalidCreds = Driver.driver.findElement(By.id("spanMessage")).getText();
102 | // String errorInvalidCreds = Driver.threadLocal.get().findElement(By.id("spanMessage")).getText();
103 | String errorInvalidCreds = DriverManager.getDriver().findElement(By.id("spanMessage")).getText();
104 |
105 |
106 | // Assert.assertEquals(errorInvalidCreds, "Invalid credentials",
107 | // "Assertion for Invalid credentials Error message");
108 | Assert.assertEquals(errorInvalidCreds, "无效的凭证",
109 | "Assertion for Invalid credentials Error message");
110 |
111 |
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/src/test/java/com/learning/tests/HomePageTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.tests;
12 |
13 | import com.learning.annotations.FrameworkAnnotation;
14 | import com.learning.driver.DriverManager;
15 | import com.learning.enums.AuthorType;
16 | import com.learning.enums.CategoryType;
17 | import com.learning.pages.HomePage;
18 | import com.learning.pages.LoginPage;
19 | import com.learning.testdata.TestData;
20 | import com.learning.utils.DataProviderUtils;
21 | import com.learning.utils.VerificationUtils;
22 | import org.testng.Assert;
23 | import org.testng.annotations.Test;
24 |
25 | import static com.learning.constants.FrameworkConstants.ASSERTION_FOR;
26 |
27 | public class HomePageTest extends BaseTest {
28 |
29 | @FrameworkAnnotation(author = { AuthorType.GAUTAM, AuthorType.PANKAJ},
30 | category = { CategoryType.SANITY, CategoryType.SMOKE,CategoryType.REGRESSION })
31 | @Test(groups = {"SANITY","SMOKE","REGRESSION"},description = "To check whether the User can login and title is displayed correctly",
32 | dataProvider = "getTestData",dataProviderClass = DataProviderUtils.class)
33 | public void titleValidationTest(TestData testData) {
34 |
35 | LoginPage loginPage = new LoginPage();
36 | HomePage homePage = loginPage
37 | .loginToApplication(testData.getUsername(), testData.getPassword());
38 |
39 | // Assert.assertEquals(homePage.getHomePageTitle(), testData.getExpectedTitle(),
40 | // "Assertion for Page Title after successful Login");
41 |
42 | VerificationUtils.validateResponse(homePage.getHomePageTitle(), testData.getExpectedTitle(),
43 | ASSERTION_FOR +" - Page Title after successful Login ");
44 |
45 | }
46 |
47 |
48 |
49 | /**
50 | * --------------------------------------------------------------------- (2nd time)
51 | * */
52 | // @FrameworkAnnotation(author = { AuthorType.GAUTAM, AuthorType.PANKAJ},
53 | // category = { CategoryType.SANITY, CategoryType.SMOKE,CategoryType.REGRESSION })
54 | // @Test(description = "To check whether the User can login and title is displayed correctly",
55 | // dataProvider = "getValidLoginData", dataProviderClass = DataProviderUtils.class)
56 | public void REFERENCE_titleValidationTest(String username, String password, String expectedTitle) {
57 |
58 | LoginPage loginPage = new LoginPage();
59 | // loginPage.setUsername("Admin");
60 | // loginPage.setPassword("admin1234");
61 | // loginPage.setUsername(username);
62 | // loginPage.setPassword(password);
63 | // loginPage.clickLogin();
64 |
65 | // Method Chaining
66 | // loginPage
67 | // .setUsername(username)
68 | // .setPassword(password)
69 | // .clickLogin();
70 | HomePage homePage = loginPage
71 | .loginToApplication(username, password);
72 |
73 | // Assert.assertEquals(DriverManager.getDriver().getTitle(), "OrangeHRM", "Assertion for Page Title after successful Login");
74 | Assert.assertEquals(homePage.getHomePageTitle(), expectedTitle,
75 | "Assertion for Page Title after successful Login");
76 |
77 | }
78 |
79 |
80 | /**
81 | * --------------------------------------------------------------------- (1st time)
82 | * */
83 | // @Test(description = "To check whether the User can login and title is displayed correctly")
84 | public void REFERENCE_errorInvalidCredentials() {
85 | // driver.findElement(By.id("txtUsername")).sendKeys("Admin");
86 | // driver.findElement(By.id("txtPassword")).sendKeys("admin1234");
87 | // driver.findElement(By.id("btnLogin")).click();
88 | // holdScript(3);
89 | // Driver.driver.findElement(By.id("txtUsername")).sendKeys("Admin");
90 | // Driver.driver.findElement(By.id("txtPassword")).sendKeys("admin1234");
91 | // Driver.driver.findElement(By.id("btnLogin")).click();
92 |
93 | // Driver.threadLocal.get().findElement(By.id("txtUsername")).sendKeys("Admin");
94 | // Driver.threadLocal.get().findElement(By.id("txtPassword")).sendKeys("admin1234");
95 | // Driver.threadLocal.get().findElement(By.id("btnLogin")).click();
96 |
97 | // DriverManager.getDriver().findElement(By.id("txtUsername")).sendKeys("Admin");
98 | // DriverManager.getDriver().findElement(By.id("txtPassword")).sendKeys("admin1234");
99 | // DriverManager.getDriver().findElement(By.id("btnLogin")).click();
100 |
101 | // LoginPage loginPage =new LoginPage();
102 | // loginPage.setUsername("Admin");
103 | // loginPage.setPassword("admin1234");
104 | // loginPage.clickLogin();
105 |
106 | // Assert.assertEquals( Driver.driver.getTitle(), "OrangeHRM", "Assertion for Page Title");
107 | // Assert.assertEquals( Driver.threadLocal.get().getTitle(), "OrangeHRM", "Assertion for Page Title");
108 | Assert.assertEquals(DriverManager.getDriver().getTitle(), "OrangeHRM", "Assertion for Page Title");
109 |
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/test/java/com/learning/tests/LoginTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.tests;
12 |
13 | import com.learning.annotations.FrameworkAnnotation;
14 | import com.learning.driver.DriverManager;
15 | import com.learning.enums.AuthorType;
16 | import com.learning.enums.CategoryType;
17 | import com.learning.pages.LoginPage;
18 | import com.learning.testdata.TestData;
19 | import com.learning.utils.DataProviderUtils;
20 | import com.learning.utils.VerificationUtils;
21 | import org.openqa.selenium.By;
22 | import org.testng.Assert;
23 | import org.testng.annotations.Test;
24 |
25 | import static com.learning.constants.FrameworkConstants.ASSERTION_FOR;
26 |
27 | public class LoginTest extends BaseTest {
28 |
29 | @FrameworkAnnotation(author = {AuthorType.RAJAT, AuthorType.NISHANT},
30 | category = {CategoryType.BVT, CategoryType.REGRESSION})
31 | @Test(groups = {"BVT","REGRESSION"},description = "To check whether the User can not login with Invalid Credentials",
32 | dataProvider = "getTestData", dataProviderClass = DataProviderUtils.class)
33 | public void errorInvalidCredentials(TestData testData) {
34 |
35 | LoginPage loginPage = new LoginPage();
36 | loginPage.loginToApplication(testData.getUsername(), testData.getPassword());
37 | String errorInvalidCreds = loginPage.getErrorMessage();
38 |
39 | // Assert.assertEquals(errorInvalidCreds, testData.getExpectedError(),
40 | // "Assertion for Invalid credentials Error message");
41 |
42 | VerificationUtils.validateResponse(errorInvalidCreds,testData.getExpectedError(),
43 | ASSERTION_FOR +" - Invalid credentials Error message ");
44 |
45 | }
46 |
47 |
48 | /**
49 | * --------------------------------------------------------------------- (2nd time)
50 | */
51 | // @FrameworkAnnotation(author = { AuthorType.RAJAT, AuthorType.NISHANT},
52 | // category = { CategoryType.BVT,CategoryType.REGRESSION })
53 | // @Test(description = "To check whether the User can not login with Invalid Credentials",
54 | // dataProvider = "getInvalidLoginData",dataProviderClass = DataProviderUtils.class)
55 | public void REFERENCE_errorInvalidCredentials(String username, String password, String expectedError) {
56 |
57 | LoginPage loginPage = new LoginPage();
58 | // loginPage.setUsername("Admin");
59 | // loginPage.setPassword("admin1234");
60 | // loginPage.setUsername(username);
61 | // loginPage.setPassword(password);
62 | // loginPage.clickLogin();
63 |
64 | // Method Chaining
65 | // loginPage
66 | // .setUsername(username)
67 | // .setPassword(password)
68 | // .clickLogin();
69 | loginPage.loginToApplication(username, password);
70 |
71 | String errorInvalidCreds = DriverManager.getDriver().findElement(By.id("spanMessage")).getText();
72 | Assert.assertEquals(errorInvalidCreds, expectedError,
73 | "Assertion for Invalid credentials Error message");
74 | }
75 |
76 |
77 | /**
78 | * --------------------------------------------------------------------- (1st time)
79 | */
80 |
81 | // @Test(description = "To check whether the User can not login with Invalid Credentials")
82 | public void REFERENCE__errorInvalidCredentials() {
83 | // driver.findElement(By.id("txtUsername")).sendKeys("Admin");
84 | // driver.findElement(By.id("txtPassword")).sendKeys("admin1234");
85 | // driver.findElement(By.id("btnLogin")).click();
86 | // holdScript(3);
87 |
88 | // Driver.threadLocal.get().findElement(By.id("txtUsername")).sendKeys("Admin");
89 | // Driver.threadLocal.get().findElement(By.id("txtPassword")).sendKeys("admin1234");
90 | // Driver.threadLocal.get().findElement(By.id("btnLogin")).click();
91 |
92 | // DriverManager.getDriver().findElement(By.id("txtUsername")).sendKeys("Admin");
93 | // DriverManager.getDriver().findElement(By.id("txtPassword")).sendKeys("admin1234");
94 | // DriverManager.getDriver().findElement(By.id("btnLogin")).click();
95 |
96 | // LoginPage loginPage =new LoginPage();
97 | // loginPage.setUsername("Admin");
98 | // loginPage.setPassword("admin1234");
99 | // loginPage.clickLogin();
100 |
101 | // String errorInvalidCreds = Driver.driver.findElement(By.id("spanMessage")).getText();
102 | // String errorInvalidCreds = Driver.threadLocal.get().findElement(By.id("spanMessage")).getText();
103 | String errorInvalidCreds = DriverManager.getDriver().findElement(By.id("spanMessage")).getText();
104 |
105 |
106 | // Assert.assertEquals(errorInvalidCreds, "Invalid credentials",
107 | // "Assertion for Invalid credentials Error message");
108 | Assert.assertEquals(errorInvalidCreds, "无效的凭证",
109 | "Assertion for Invalid credentials Error message");
110 |
111 |
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/src/test/java/com/learning/tests/LogoutTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | * Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | */
10 |
11 | package com.learning.tests;
12 |
13 | import com.learning.annotations.FrameworkAnnotation;
14 | import com.learning.driver.DriverManager;
15 | import com.learning.enums.AuthorType;
16 | import com.learning.enums.CategoryType;
17 | import com.learning.pages.HomePage;
18 | import com.learning.pages.LoginPage;
19 | import com.learning.testdata.TestData;
20 | import com.learning.utils.DataProviderUtils;
21 | import org.openqa.selenium.By;
22 | import org.testng.Assert;
23 | import org.testng.annotations.Test;
24 |
25 | public class LogoutTest extends BaseTest {
26 |
27 | @FrameworkAnnotation(author = {AuthorType.RAJAT, AuthorType.NISHANT},
28 | category = {CategoryType.BVT, CategoryType.SANITY, CategoryType.REGRESSION})
29 | @Test(groups = {"BVT","SANITY","REGRESSION"},description = "To check whether the User can logout from the application.",
30 | dataProvider = "getTestData", dataProviderClass = DataProviderUtils.class)
31 | public void logoutTest(TestData testData) {
32 |
33 | LoginPage loginPage = new LoginPage();
34 | HomePage homePage = loginPage.loginToApplication(testData.getUsername(), testData.getPassword());
35 | homePage.logoutFromApplication();
36 |
37 | Assert.assertTrue(loginPage.getTxtBoxUserame().isDisplayed(),
38 | "Assertion for TextBox Username presence");
39 | Assert.assertTrue(loginPage.getTxtBoxPassword().isDisplayed(),
40 | "Assertion for TextBox Password presence");
41 | Assert.assertTrue(loginPage.getBtnLogin().isDisplayed(),
42 | "Assertion for Button Login presence");
43 | }
44 |
45 |
46 | /**
47 | * --------------------------------------------------------------------- (2nd time)
48 | */
49 | // @FrameworkAnnotation(author = { AuthorType.RAJAT, AuthorType.NISHANT},
50 | // category = { CategoryType.BVT,CategoryType.REGRESSION })
51 | // @Test(description = "To check whether the User can not login with Invalid Credentials",
52 | // dataProvider = "getInvalidLoginData",dataProviderClass = DataProviderUtils.class)
53 | public void REFERENCE_errorInvalidCredentials(String username, String password, String expectedError) {
54 |
55 | LoginPage loginPage = new LoginPage();
56 | // loginPage.setUsername("Admin");
57 | // loginPage.setPassword("admin1234");
58 | // loginPage.setUsername(username);
59 | // loginPage.setPassword(password);
60 | // loginPage.clickLogin();
61 |
62 | // Method Chaining
63 | // loginPage
64 | // .setUsername(username)
65 | // .setPassword(password)
66 | // .clickLogin();
67 | loginPage.loginToApplication(username, password);
68 |
69 | String errorInvalidCreds = DriverManager.getDriver().findElement(By.id("spanMessage")).getText();
70 | Assert.assertEquals(errorInvalidCreds, expectedError,
71 | "Assertion for Invalid credentials Error message");
72 | }
73 |
74 |
75 | /**
76 | * --------------------------------------------------------------------- (1st time)
77 | */
78 |
79 | // @Test(description = "To check whether the User can not login with Invalid Credentials")
80 | public void REFERENCE__errorInvalidCredentials() {
81 | // driver.findElement(By.id("txtUsername")).sendKeys("Admin");
82 | // driver.findElement(By.id("txtPassword")).sendKeys("admin1234");
83 | // driver.findElement(By.id("btnLogin")).click();
84 | // holdScript(3);
85 |
86 | // Driver.threadLocal.get().findElement(By.id("txtUsername")).sendKeys("Admin");
87 | // Driver.threadLocal.get().findElement(By.id("txtPassword")).sendKeys("admin1234");
88 | // Driver.threadLocal.get().findElement(By.id("btnLogin")).click();
89 |
90 | // DriverManager.getDriver().findElement(By.id("txtUsername")).sendKeys("Admin");
91 | // DriverManager.getDriver().findElement(By.id("txtPassword")).sendKeys("admin1234");
92 | // DriverManager.getDriver().findElement(By.id("btnLogin")).click();
93 |
94 | // LoginPage loginPage =new LoginPage();
95 | // loginPage.setUsername("Admin");
96 | // loginPage.setPassword("admin1234");
97 | // loginPage.clickLogin();
98 |
99 | // String errorInvalidCreds = Driver.driver.findElement(By.id("spanMessage")).getText();
100 | // String errorInvalidCreds = Driver.threadLocal.get().findElement(By.id("spanMessage")).getText();
101 | String errorInvalidCreds = DriverManager.getDriver().findElement(By.id("spanMessage")).getText();
102 |
103 |
104 | // Assert.assertEquals(errorInvalidCreds, "Invalid credentials",
105 | // "Assertion for Invalid credentials Error message");
106 | Assert.assertEquals(errorInvalidCreds, "无效的凭证",
107 | "Assertion for Invalid credentials Error message");
108 |
109 |
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/test/resources/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/TMB_SeleniumFramework2/99452e2b553199c1dcf6a24dfbc06ae16fcc5771/src/test/resources/.DS_Store
--------------------------------------------------------------------------------
/src/test/resources/config/config.properties:
--------------------------------------------------------------------------------
1 | #/**
2 | #* @author Rajat Verma
3 | #* https://www.linkedin.com/in/rajat-v-3b0685128/
4 | #* https://github.com/rajatt95
5 | #* https://rajatt95.github.io/
6 | #*
7 | #* Course: Selenium - Java with Docker, Git and Jenkins (https://www.testingminibytes.com/courses/selenium-java-with-docker-git-and-jenkins/)
8 | #* Tutor: Amuthan Sakthivel (https://www.testingminibytes.com/)
9 | #*/
10 | #
11 | timeout=10
12 | url=https://opensource-demo.orangehrmlive.com/
13 |
14 | #local -> chrome,chrome_headless,firefox,edge,opera,safari
15 | #remote -> chrome,firefox,edge
16 | browser=chrome
17 |
18 | #local, remote
19 | runmode=local
20 | remoteUrl=http://localhost:4444/wd/hub
21 |
22 | #override_reports --> yes or no
23 | #If no -> Report name will be like
24 | # - Windows_10_Tue_Oct_05_02_30_46_IST_2021_AutomationReport.html
25 | # - Mac_OS_X_Tue_Feb_22_16_10_47_IST_2022_AutomationReport.html
26 | #If yes -> Report name will be AutomationReport.html
27 | override_reports=yes
28 |
29 | #open_reports_after_execution--> yes or no
30 | open_reports_after_execution=yes
31 |
32 | #send_email_to_users --> yes or no
33 | #If yes -> then, provide your mail credentials -> src/main/java -> package com.learning.java_Mail_API.EmailConfig;
34 | #This Email will be sent using Java mail API
35 | send_email_to_users=no
36 |
37 | #retry failed test cases -> yes or no
38 | #It will try for 1 time if any Test case gets failed
39 | retry_failed_tests=yes
40 |
41 | #PassedStepsScreenshot --> yes or no
42 | passed_steps_screenshot=no
43 |
44 | #FailedStepsScreenshot --> yes or no
45 | failed_steps_screenshot=yes
46 |
47 | #SkippedStepsScreenshot --> yes or no
48 | skipped_steps_screenshot=yes
--------------------------------------------------------------------------------
/src/test/resources/runners/testng.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/test/resources/runners/testng_SAFARI.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/resources/testdata/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/TMB_SeleniumFramework2/99452e2b553199c1dcf6a24dfbc06ae16fcc5771/src/test/resources/testdata/.DS_Store
--------------------------------------------------------------------------------
/src/test/resources/testdata/testData.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/TMB_SeleniumFramework2/99452e2b553199c1dcf6a24dfbc06ae16fcc5771/src/test/resources/testdata/testData.xlsx
--------------------------------------------------------------------------------
/src/test/resources/testdata/testData_rough.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/TMB_SeleniumFramework2/99452e2b553199c1dcf6a24dfbc06ae16fcc5771/src/test/resources/testdata/testData_rough.xlsx
--------------------------------------------------------------------------------