diff --git a/pom.xml b/pom.xml index eb86ba3..166ff0c 100644 --- a/pom.xml +++ b/pom.xml @@ -12,13 +12,13 @@ 1.8.10 UTF-8 11 - 4.6.0 + 4.14.1 3.10.1 - 1.18.24 + 1.18.26 7.7.0 2.0.0 1.0.2 - 5.2.1 + 5.5.3 UTF-8 ${java.version} ${java.version} @@ -46,18 +46,6 @@ provided - - org.slf4j - slf4j-jdk14 - ${slf4j.version} - - - - com.tesults.testng - tesults-testng - ${tesults.version} - - io.github.bonigarcia webdrivermanager diff --git a/src/main/java/com/praveenkh/pages/HomePageFooter.java b/src/main/java/com/praveenkh/pages/HomePageFooter.java deleted file mode 100644 index 0948e4e..0000000 --- a/src/main/java/com/praveenkh/pages/HomePageFooter.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.praveenkh.pages; - -import driverEngine.BrowserActions; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.testng.Assert; - -public class HomePageFooter { - - private final BrowserActions browserActions; - final By copyRightInFooter = By.xpath("//*[@id=\"84018e6c-a859-4f30-b691-b5ffe8050167\"]/div/section/div[1]/div/div/div[1]/div/p/span"); - final By badmintonInFooter = By.xpath("//*[@id=\"84018e6c-a859-4f30-b691-b5ffe8050167\"]/div/section/div[2]/ul/li[1]/a"); - final By privacyPolicyInFooter = By.xpath("//a[normalize-space()='Privacy Policy']"); - final By privacyPolicyPageHeader = By.xpath("//*[@id=\"563e12cf-1420-4b37-991c-e03e67767a88\"]/div/section/div/div/div/div/div/span"); - final By termsAndConditionsInFooter = By.xpath("//a[normalize-space()='Terms and Conditions']"); - final By termsAndConditionsPageHeader = By.xpath("//*[@id=\"92a074a7-313e-4fcc-ac20-f9fb2271a0cc\"]/div/section/div/h1/span"); - - public HomePageFooter(WebDriver driver) { - browserActions = new BrowserActions(driver); - - //TODO Check that we're on the right page by asserting page title or URL - } - - public void validateCopyright() { - final String COPYRIGHT_TEXT_FOOTER = "Copyright © 2022 Praveen K H - All Rights Reserved."; - Assert.assertEquals(COPYRIGHT_TEXT_FOOTER, browserActions.getTextFromElement(copyRightInFooter), "Copyright text mismatch at footer"); - } - - public void validateBadminton() { - final String YOUTUBE_CHANNEL_LINK = "https://www.youtube.com/channel/UCOmpwPOwUWrWejxsI-gRlbg"; - Assert.assertEquals("BADMINTON", browserActions.getTextFromElement(badmintonInFooter), "Copyright text mismatch at footer"); - Assert.assertEquals(YOUTUBE_CHANNEL_LINK, browserActions.getAttributeFromElement(badmintonInFooter, "href"), "Copyright link mismatch at footer"); - // TODO Check if the YouTube Href is 200 or not - } - - public HomePageFooter validatePrivacyPolicy() { - final String PRIVACY_POLICY_LINK = "https://praveenkh.com/privacy-policy"; - Assert.assertEquals("PRIVACY POLICY", browserActions.getTextFromElement(privacyPolicyInFooter), "PrivacyPolicy text mismatch at footer"); - Assert.assertEquals(PRIVACY_POLICY_LINK, browserActions.getAttributeFromElement(privacyPolicyInFooter,"href"), "Privacy policy link mismatch at footer"); - return this; - } - - public HomePageFooter clickOnPrivacyPolicy() { - browserActions.clickOnElement(privacyPolicyInFooter); - final String PRIVACY_PAGE_URL = "https://praveenkh.com/privacy-policy"; - Assert.assertEquals(PRIVACY_PAGE_URL, browserActions.getCurrentUrl(), "Page Url mismatch privacy-policy"); - return this; - } - - public void validatePrivacyPolicyPageContent() { - Assert.assertEquals("Privacy Policy coming soon", browserActions.getTextFromElement(privacyPolicyPageHeader), "Privacy Policy page content mismatch"); - } - - public HomePageFooter validateTermsAndConditions() { - final String TERMS_AND_CONDITIONS_LINK = "https://praveenkh.com/terms-and-conditions"; - Assert.assertEquals("TERMS AND CONDITIONS", browserActions.getTextFromElement(termsAndConditionsInFooter), "Terms and Conditions text mismatch at footer"); - Assert.assertEquals(TERMS_AND_CONDITIONS_LINK, browserActions.getAttributeFromElement(termsAndConditionsInFooter,"href"), "Terms and Conditions link mismatch at footer"); - return this; - } - - public HomePageFooter clickOnTermsAndConditions() { - browserActions.clickOnElement(termsAndConditionsInFooter); - final String TERMS_AND_CONDITIONS_PAGE_URL = "https://praveenkh.com/terms-and-conditions"; - Assert.assertEquals(TERMS_AND_CONDITIONS_PAGE_URL, browserActions.getCurrentUrl(), "Page Url mismatch at terms-and-conditions"); - return this; - } - - public void validateTermsAndConditionsPageContent() { - Assert.assertEquals("TERMS AND CONDITIONS", browserActions.getTextFromElement(termsAndConditionsPageHeader), "Terms and Conditions page content mismatch"); - } -} diff --git a/src/main/java/driverEngine/BrowserEngine.java b/src/main/java/driverEngine/BrowserEngine.java index 0b70ad5..968790f 100644 --- a/src/main/java/driverEngine/BrowserEngine.java +++ b/src/main/java/driverEngine/BrowserEngine.java @@ -23,9 +23,8 @@ public static WebDriver getFirefoxDriver() { } public static WebDriver getChromeDriver() { - ChromeOptions options = new ChromeOptions(); - - options.addArguments("--headless", + final ChromeOptions options = new ChromeOptions(); + options.addArguments("--headless=new", "--disable-gpu", "--window-size=1920,1200", "--ignore-certificate-errors", @@ -37,7 +36,7 @@ public static WebDriver getChromeDriver() { log.info("Chrome driver started successfully"); driver = new ChromeDriver(options); - driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); + driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); driver.manage().window().maximize(); return driver; } diff --git a/src/test/java/com/praveenkh/AllLinksTest.java b/src/test/java/com/praveenkh/AllLinksTest.java deleted file mode 100644 index 2805dc6..0000000 --- a/src/test/java/com/praveenkh/AllLinksTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.praveenkh; - -import driverEngine.BrowserActions; -import driverEngine.BrowserEngine; -import lombok.extern.java.Log; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; - -@Log -public class AllLinksTest { - - private static WebDriver driver; - private static BrowserActions browserActions; - private final String SITE = "https://www.praveenkh.com/"; - - @BeforeClass(alwaysRun = true) - public void startBrowser() { - driver = BrowserEngine.getChromeDriver(); - browserActions = new BrowserActions(driver); - - log.info("Navigate to Home page before"); - driver.navigate().to(SITE); - } - - @DataProvider(name = "allLinks") - public Object[][] ab() { - final List linksList = browserActions.getAllHrefLinksFromPage(); - - Object [][] objArray = new Object[linksList.size()][]; - for(int i=0;i< linksList.size();i++){ - objArray[i] = new Object[1]; - objArray[i][0] = linksList.get(i).getAttribute("href"); - } - return objArray; - } - - - @Test(dataProvider = "allLinks") - public void validateAllLinksWorking(final String link) { - - final String url = link; - log.info("Url under test : [ " + url + " ]"); - if (url == null || url.isEmpty()) { - System.out.println("URL is either not configured for anchor tag or it is empty"); - } - - try { - final HttpURLConnection huc = (HttpURLConnection) (new URL(url).openConnection()); - huc.setRequestMethod("HEAD"); - huc.connect(); - final int respCode = huc.getResponseCode(); - Assert.assertEquals(respCode, 200, "Broken Link : [ " + url + " ]"); - - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - - @AfterClass - public void quiteBrowser() { - log.info("Quit driver after test"); - driver.quit(); - } - -} diff --git a/src/test/java/com/praveenkh/FooterTests.java b/src/test/java/com/praveenkh/FooterTests.java deleted file mode 100644 index 30b213d..0000000 --- a/src/test/java/com/praveenkh/FooterTests.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.praveenkh; - -import com.praveenkh.pages.HomePageFooter; -import driverEngine.BrowserEngine; -import lombok.extern.java.Log; -import org.openqa.selenium.WebDriver; -import org.testng.annotations.*; - -@Log -public class FooterTests { - - private static WebDriver driver; - private HomePageFooter homePageFooter; - - private final String SITE = "https://www.praveenkh.com/"; - - @BeforeClass(alwaysRun = true) - public void startBrowser() { - driver = BrowserEngine.getChromeDriver(); - homePageFooter = new HomePageFooter(driver); - } - - @BeforeMethod(alwaysRun = true) - public void beforeTestNavigateToHomePage() { - log.info("Navigate to Home page before"); - driver.navigate().to(SITE); - } - - @Test() - public void ValidateCopyright() { - homePageFooter.validateCopyright(); - } - - @Test() - public void ValidateBadminton() { - homePageFooter.validateBadminton(); - } - - @Test() - public void ValidatePrivacyPolicy() { - homePageFooter - .validatePrivacyPolicy() - .clickOnPrivacyPolicy() - .validatePrivacyPolicyPageContent(); - } - - @Test() - public void ValidateTermsAndConditions() { - homePageFooter - .validateTermsAndConditions() - .clickOnTermsAndConditions() - .validateTermsAndConditionsPageContent(); - } - - @AfterClass - public void quiteBrowser() { - log.info("Quit driver after test"); - driver.quit(); - } -} diff --git a/testNGsuite/praveen.xml b/testNGsuite/praveen.xml deleted file mode 100644 index 795c06d..0000000 --- a/testNGsuite/praveen.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/tesults.properties b/tesults.properties deleted file mode 100644 index 5748fce..0000000 --- a/tesults.properties +++ /dev/null @@ -1,2 +0,0 @@ -default=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6Ijc3ZjNhMjZjLTk0Y2UtNDMxMS1iYzQzLWIxMTEyMDUzZGEwMC0xNjY1NDA0ODIxNDc3IiwiZXhwIjo0MTAyNDQ0ODAwMDAwLCJ2ZXIiOiIwIiwic2VzIjoiYzUxNjY3ODMtNDYyNC00MGFkLTkyMDEtZmMwYTA4NjgxNDY4IiwidHlwZSI6InQifQ.UQHIG1t2bMhajpAfAa2V7sXo66i6mYa_4zVIJWGM8-M -djibangalore=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6Ijc3ZjNhMjZjLTk0Y2UtNDMxMS1iYzQzLWIxMTEyMDUzZGEwMC0xNjY3OTI4NTc2NTI1IiwiZXhwIjo0MTAyNDQ0ODAwMDAwLCJ2ZXIiOiIwIiwic2VzIjoiMjliMDdmZDktOGNlOS00YzlhLTlkNjQtMmVlYTJiMDRkYTQ2IiwidHlwZSI6InQifQ.ATGLiiUolRdRXrVxasiJ7L_RZctTcSZ0r9OCN9joG5w \ No newline at end of file