getPredicate(String value){
31 | return MAP.get(value);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/automation/driver/Driver.java:
--------------------------------------------------------------------------------
1 | package com.automation.driver;
2 |
3 | import com.automation.config.ConfigFactory;
4 | import com.automation.driver.entity.DriverData;
5 | import com.automation.driver.manager.DriverManager;
6 | import com.automation.enums.BrowserType;
7 | import com.automation.driver.factory.DriverFactory;
8 | import lombok.AccessLevel;
9 | import lombok.NoArgsConstructor;
10 |
11 | import java.util.Objects;
12 |
13 | /**
14 | * Driver class is responsible for invoking and closing the browsers.
15 | *
16 | * It is also responsible for setting the driver variable to DriverManager which handles the thread safety for the webdriver instance.
17 | *
18 | * @author Administrator
19 | */
20 | @NoArgsConstructor(access = AccessLevel.PRIVATE)
21 | public final class Driver {
22 |
23 | public static void initDriver(BrowserType browser) {
24 | DriverData driverData = DriverData.builder()
25 | .browserType(browser)
26 | .browserRemoteModeType(ConfigFactory.getConfig().remote_mode())
27 | .build();
28 |
29 | if (Objects.isNull(DriverManager.getDriver())) {
30 | DriverManager.setDriver(DriverFactory
31 | .getDriver(ConfigFactory.getConfig().run_mode())
32 | .getDriver(driverData));
33 | }
34 | DriverManager.getDriver().get(ConfigFactory.getConfig().url());
35 | DriverManager.getDriver().manage().window().maximize();
36 | }
37 |
38 | public static void quitDriver() {
39 | if (Objects.nonNull(DriverManager.getDriver())) {
40 | DriverManager.getDriver().quit();
41 | DriverManager.unload();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/com/automation/pages/orangehrm/HomePageAssert.java:
--------------------------------------------------------------------------------
1 | package com.automation.pages.orangehrm;
2 |
3 | import com.automation.pages.orangehrm.validator.HomePageValidator;
4 | import org.assertj.core.api.AbstractAssert;
5 | import org.assertj.core.api.SoftAssertions;
6 |
7 | public class HomePageAssert extends AbstractAssert {
8 |
9 | private final SoftAssertions softAssertions;
10 |
11 | private HomePageAssert(HomePageValidator homePageValidator) {
12 | super(homePageValidator, HomePageAssert.class);
13 | softAssertions = new SoftAssertions();
14 | }
15 |
16 | public static HomePageAssert assertThat(HomePageValidator homePageValidator) {
17 | return new HomePageAssert(homePageValidator);
18 | }
19 |
20 | public HomePageAssert headerNameEquals(String expectedHeaderName) {
21 | String actualHeaderName = actual.getHeaderName();
22 | softAssertions.assertThat(actualHeaderName)
23 | .isEqualTo(expectedHeaderName);
24 | return this;
25 | }
26 |
27 | public HomePageAssert logoSourceStringContains(String expectedLogoSourceString) {
28 | String actualLogoSourceText = actual.getLogoSourceText();
29 | softAssertions.assertThat(actualLogoSourceText)
30 | .isEqualTo(expectedLogoSourceString);
31 | return this;
32 | }
33 |
34 | public HomePageAssert isMarketPlaceLinkPresent() {
35 | softAssertions.assertThat(actual.isMarketPlaceLinkPresent())
36 | .withFailMessage(()->"Market Place link not present")
37 | .isTrue();
38 | return this;
39 | }
40 |
41 | public void assertAll() {
42 | softAssertions.assertAll();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/com/automation/utils/dataprovider/DataProviderUtils.java:
--------------------------------------------------------------------------------
1 | package com.automation.utils.dataprovider;
2 |
3 | import com.automation.constants.FrameworkConstants;
4 | import com.automation.utils.zerocell.ExcelReader;
5 | import lombok.AccessLevel;
6 | import lombok.NoArgsConstructor;
7 | import org.testng.annotations.DataProvider;
8 | import java.lang.reflect.Method;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.Map;
12 | import java.util.function.Predicate;
13 |
14 | @NoArgsConstructor(access = AccessLevel.PRIVATE)
15 | public final class DataProviderUtils {
16 |
17 | private static List