Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.zaizi.automation.alfresco; import com.relevantcodes.extentreports.ExtentReports; import com.relevantcodes.extentreports.ExtentTest; import com.relevantcodes.extentreports.LogStatus; import com.zaizi.automation.alfresco.core.elements.Button; import com.zaizi.automation.alfresco.core.elements.Element; import com.zaizi.automation.alfresco.core.elements.Link; import com.zaizi.automation.alfresco.core.elements.Span; import com.zaizi.automation.alfresco.core.elements.TextField; import com.zaizi.automation.alfresco.core.info.TestCaseProperties; import com.zaizi.automation.alfresco.core.info.TestCaseValues; import com.zaizi.automation.alfresco.core.pages.CreateObjects; import com.zaizi.automation.alfresco.core.pages.LoginPage; import com.zaizi.automation.alfresco.core.pages.NavigateToPage; import com.zaizi.automation.alfresco.core.pages.RemoveObjects; import com.zaizi.automation.alfresco.core.pages.SearchObjects; import com.zaizi.automation.alfresco.core.pages.SiteDashboardPage; import com.zaizi.automation.alfresco.reportsetup.ExtentManager; import com.zaizi.automation.exceptions.IterableException; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.junit.runners.Parameterized; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; import org.openqa.selenium.OutputType; import org.openqa.selenium.Point; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.Augmenter; /** * * @author mketheeswaran */ @RunWith(value = Parameterized.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class F_Vanila_DocumentLibraryTest_Chrome { /** * * Defining log4j */ public static final Logger LOGGER = LogManager.getLogger(F_Vanila_DocumentLibraryTest_Chrome.class.getName()); /** * * Defining Report */ static ExtentReports extent; //ExtentReports extent = new ExtentReports(TestCaseProperties.REPORT_TEST_PATH_CHROME+className+".html",true); /** * * Define WebDriver */ private static WebDriver driver; /** * Define siteName */ private String siteName; /** * Define siteId */ private String siteId; /** * Define Private site creator Name */ private String siteCreatorName; /** * Define isPrivate */ private Boolean isPrivate; /** * Define expectResult For Site */ private String expectedResult; /** * Define documentName */ private String documentName; /** * Define userName */ private String userName; /** * Define roleName */ private String roleName; /** * * Define ScreenShotName */ private String screenShotName; /** * * Define className */ public static String className = F_Vanila_DocumentLibraryTest_Chrome.class.getSimpleName(); /** * parameters pass via this constructor * */ public F_Vanila_DocumentLibraryTest_Chrome(String siteName, String siteId, String siteCreatorName, Boolean isPrivate, String expectedResult, String documentName, String userName, String roleName, String screenShotName) { this.siteName = siteName; this.siteId = siteId; this.siteCreatorName = siteCreatorName; this.isPrivate = isPrivate; this.expectedResult = expectedResult; this.documentName = documentName; this.userName = userName; this.roleName = roleName; this.screenShotName = screenShotName; } /** * * Declares parameters here * @return * * @throws Exception */ @Parameterized.Parameters() public static Iterable<Object[]> data() throws IterableException { LOGGER.info(TestCaseProperties.TEXT_TEST_PREPARING, "F_Vanila_DocumentLibraryTest_Chrome"); return TestCaseValues.documentLibraryTestValues("F_Vanila_DocumentLibraryTest_Chrome"); } /** * * Declares ExtentReports Configurations here * SeleniumWebdriver Specification (Set capabilities of Platform,BrowserName,Version) * RemoteWebdriver Specification(new RemoteWebDriver(new URL(NODEURL),capability)) * Grid Specification * * @return * * @throws Exception */ @BeforeClass public static void beforeClass() throws IOException { //Add CustomStyles to testReport //String css = "div.content{ width: 1422px;}"+ "div.filters{ width:1422px;}"; extent = ExtentManager.getReporter(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + ".html"); //Initialize ExtentReport(driver,NameofReport) //Element.reportInitialChrome(driver, className); //test.config().addCustomStyles(css); //Define DocumentTitle of ExtentReport //test.config().documentTitle("Automation Report"); //Define ReportTitle of ExtentReport //test.config().reportTitle("Regression"); //Define ReportHeadLine of ExtentReport //test.config().reportHeadline("Login Testing"); } /** * * Setup Requirements for Below TestCase * user "Test" EXIST * CAPTCHA enable=False * Login Attempts delay by=5 minutes */ @Test public void a_preRequest() throws InterruptedException, IOException { LOGGER.info(TestCaseProperties.TEXT_TEST_EXECUTING, "Setup Requirements"); ExtentTest test = extent.startTest("Setup Requirements"); LOGGER.info("1 ) user \"privateuser\" / \"privateuser\" exists,"); LOGGER.info("2 ) password of \"privateuser\" is \"1qaz@WSX\" "); test.log(LogStatus.INFO, "1 ) user \"privateuser\" / \"privateuser\" exists"); test.log(LogStatus.INFO, "2 ) password of \"privateuser\" is \"1qaz@WSX\" "); extent.endTest(test); extent.flush(); } /** * * @Test createSite * @return * * @throws Exception InterruptedException, IOException */ @Test public void b_createSite() throws InterruptedException, IOException { LOGGER.info(TestCaseProperties.TEXT_TEST_EXECUTING, "Create Site " + siteName); //Extent Report Start Configuration(testCaseName,Definition of testCase) ExtentTest test = extent.startTest("b_createSite", "Create site called \" " + siteName + " \",Is it private Site " + isPrivate); //Set the DriverType(BrowserName,Platform) driver = TestCaseProperties.driverType("Chrome", "WINDOWS"); // Set the upper left corner of the screen starting point driver.manage().window().setPosition(new Point(0, 0)); // define screen size java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); // define desired size Dimension maxWindowSize = new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight()); // Maximize the browser window according to your system's current // resolution(set desired size) driver.manage().window().setSize(maxWindowSize); //Get LoginScreen_URl from TestcaseProperties Values driver.get(TestCaseProperties.LOGIN_SCREEN_URL); LOGGER.info("Test case b_createSite started executing"); test.log(LogStatus.INFO, "Test case b_createSite started executing"); LOGGER.info("Accessing the Login Page"); test.log(LogStatus.INFO, "Accessing the Login Page"); LOGGER.info("Login as admin"); test.log(LogStatus.INFO, "Login as admin"); LoginPage loginPage = new LoginPage(driver); loginPage.loginAsAdmin(className, screenShotName); CreateObjects createObjects = new CreateObjects(driver); if (isPrivate) { LOGGER.info("CREATE PRIVATE SITE"); test.log(LogStatus.INFO, "CREATE PRIVATE SITE"); test.log(LogStatus.INFO, "Click \"Create Site\" "); test.log(LogStatus.INFO, "Enter " + siteName + " in \"site Name Field\" "); test.log(LogStatus.INFO, "Enter " + siteId + " in \"site URL Field\" "); test.log(LogStatus.INFO, "Check \"private\" Option"); test.log(LogStatus.INFO, "Click \"OK\" Button "); createObjects.createPrivateSite(siteName, siteId, expectedResult, className, screenShotName + "private2"); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "81" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "81" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); //If Site Created if (Element.isElementPresent(driver, By.xpath("//div[@class='bd']/span[@class='wait']"))) { LOGGER.info(TestCaseProperties.TEXT_TEST_PASS, "Site " + siteName + " CREATED "); test.log(LogStatus.INFO, "<font color=blue>Site " + siteName + " CREATED <font> "); } //If Site IS NOT CREATED //Expected Result1=[COULD NOT CREATE SITE SINCE THE URL IS ALREADY USED] //ExpectedResult1==CurrentResult else { SiteDashboardPage siteDash1 = new SiteDashboardPage(driver); String siteErrorNotification = siteDash1.errorNotification(siteName, className, screenShotName); if (siteErrorNotification.toUpperCase().equals(expectedResult)) { LOGGER.info("Expected Results : " + expectedResult); test.log(LogStatus.INFO, "Expected Results : " + expectedResult); LOGGER.info("Current Test Results : " + siteErrorNotification); test.log(LogStatus.PASS, "Current Test Results : " + "<font color=green>" + siteErrorNotification + "<font>"); Button okaybtn = new Button(driver, By.xpath("//button[text()='OK']")); okaybtn.click(); } //ExpectedResult1!=CurrentResult[PROBLEM] else { LOGGER.error(TestCaseProperties.TEXT_TEST_FAIL, "Private Site " + siteName + "IS NOT CREATED "); test.log(LogStatus.FAIL, "Private Site " + siteName + "IS NOT CREATED "); LOGGER.info("Expected Results : " + expectedResult); test.log(LogStatus.INFO, "Expected Results : " + expectedResult); LOGGER.info("Current Test Results : " + siteErrorNotification); test.log(LogStatus.FAIL, "Current Test Results : " + "<font color=red>" + siteErrorNotification + "<font>"); } } Element.waitForLoad(driver); Thread.sleep(5000); LOGGER.info("CHECK WHETHER PRIVATE SITE CREATED OR NOT"); test.log(LogStatus.INFO, "CHECK WHETHER PRIVATE SITE CREATED OR NOT"); LOGGER.info("Check whether \" " + siteName + "\" SITE IS VISIBLE TO " + siteCreatorName); test.log(LogStatus.INFO, "Check whether \" " + siteName + "\" SITE IS VISIBLE TO " + siteCreatorName); Thread.sleep(5000); LOGGER.info("Search the sitename in Site finder"); test.log(LogStatus.INFO, "Search the sitename in Site finder"); SearchObjects searchSite = new SearchObjects(driver); searchSite.searchSite(siteName, className, screenShotName + "joinadmin"); if (Element.isElementPresent(driver, By.xpath("//Span[text()='No sites found']"))) { LOGGER.info("Message display as \"No sites found\""); test.log(LogStatus.INFO, "Message display as \"No sites found\""); LOGGER.info(siteName + " SITE IS NOT VISIBLE TO " + siteCreatorName); test.log(LogStatus.FAIL, "<font color=blue>" + siteName + " SITE IS NOT VISIBLE TO " + siteCreatorName + "<font>"); WebDriver augmentedDriver2 = new Augmenter().augment(driver); File screenshot2 = ((TakesScreenshot) augmentedDriver2).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot2, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "82" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "82" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else if (Element.isTextPresentInListForSite( driver.findElements(By.xpath("//tbody//tr//td//div//h3//a[contains(., '" + siteName + "')]")), siteName)) { LOGGER.info(siteName + " SITE IS VISIBLE TO " + siteCreatorName); test.log(LogStatus.INFO, "<font color=blue>" + siteName + " SITE IS VISIBLE TO " + siteCreatorName + "<font>"); WebDriver augmentedDriver3 = new Augmenter().augment(driver); File screenshot3 = ((TakesScreenshot) augmentedDriver3).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot3, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "83" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "83" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } Thread.sleep(5000); Element.waitForLoad(driver); LoginPage loginPage1 = new LoginPage(driver); loginPage1.logout(); Element.waitForLoad(driver); LOGGER.info("Login as \"privateuser\" "); test.log(LogStatus.INFO, "Login as \"privateuser\" "); loginPage1.loginAsUser1("privateuser", "1qaz@WSX"); Element.waitForLoad(driver); Thread.sleep(5000); LOGGER.info("Check whether \"" + siteName + "\" SITE IS VISIBLE TO UNJOIN USER \"privateuser\""); test.log(LogStatus.INFO, "Check whether \" " + siteName + "\" SITE IS VISIBLE TO UNJOIN USER \"privateuser\""); SearchObjects searchSite2 = new SearchObjects(driver); searchSite2.searchSite(siteName, className, screenShotName + "non join"); Element.waitForLoad(driver); if (Element.isElementPresent(driver, By.xpath("//Span[text()='No sites found']"))) { Thread.sleep(5000); LOGGER.info("Message display as \"No sites found\""); test.log(LogStatus.INFO, "Message display as \"No sites found\""); LOGGER.info(siteName + " SITE IS NOT VISIBLE TO UNJOIN USER"); test.log(LogStatus.PASS, siteName + " SITE IS NOT VISIBLE TO UNJOIN USER \"privateuser\""); WebDriver augmentedDriver3 = new Augmenter().augment(driver); File screenshot3 = ((TakesScreenshot) augmentedDriver3).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot3, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "84" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "84" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { Thread.sleep(5000); if (Element.isTextPresentInList( driver.findElements( By.xpath("//tbody//tr//td//div//h3//a[contains(., '" + siteName + "')]")), siteName)) { LOGGER.info(siteName + " SITE IS VISIBLE TO UNJOIN USER \"privateuser\""); test.log(LogStatus.FAIL, siteName + " SITE IS VISIBLE TO UNJOIN USER \"privateuser\""); WebDriver augmentedDriver3 = new Augmenter().augment(driver); File screenshot3 = ((TakesScreenshot) augmentedDriver3).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot3, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "85" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "85" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { LOGGER.info(siteName + " SITE IS NOT VISIBLE TO UNJOIN USER"); test.log(LogStatus.PASS, siteName + " SITE IS NOT VISIBLE TO UNJOIN USER \"privateuser\""); WebDriver augmentedDriver3 = new Augmenter().augment(driver); File screenshot3 = ((TakesScreenshot) augmentedDriver3).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot3, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "86" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "86" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } } } else { LOGGER.info("CREATE PUBLIC SITE"); test.log(LogStatus.INFO, "CREATE PUBLIC SITE"); test.log(LogStatus.INFO, "Click \"Create Site\" "); test.log(LogStatus.INFO, "Enter " + siteName + " in \"site Name Field\" "); test.log(LogStatus.INFO, "Enter " + siteId + " in \"site URL Field\" "); test.log(LogStatus.INFO, "Check \"private\" Option"); test.log(LogStatus.INFO, "Click \"OK\" Button "); createObjects.createPublicSite(siteName, siteId, expectedResult, className, screenShotName); //If Site Created if (Element.isElementPresent(driver, By.xpath("//div[@class='bd']/span[@class='wait']"))) { LOGGER.info(TestCaseProperties.TEXT_TEST_PASS, "Site " + siteName + " CREATED "); test.log(LogStatus.INFO, "<font color=blue>Site " + siteName + " CREATED <font> "); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "87" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "87" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } //If Site IS NOT CREATED //Expected Result1=[COULD NOT CREATE SITE SINCE THE URL IS ALREADY USED] //ExpectedResult1==CurrentResult else { SiteDashboardPage siteDash1 = new SiteDashboardPage(driver); String siteErrorNotification = siteDash1.errorNotification(siteName, className, screenShotName); if (siteErrorNotification.toUpperCase().equals(expectedResult)) { LOGGER.info("Expected Results : " + expectedResult); test.log(LogStatus.INFO, "Expected Results : " + expectedResult); LOGGER.info("Current Test Results : " + siteErrorNotification); test.log(LogStatus.PASS, "Current Test Results : " + "<font color=green>" + siteErrorNotification + "<font>"); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "88" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "88" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); Button okaybtn = new Button(driver, By.xpath("//button[text()='OK']")); okaybtn.click(); } //ExpectedResult1!=CurrentResult[PROBLEM] else { LOGGER.error(TestCaseProperties.TEXT_TEST_FAIL, "Private Site " + siteName + "IS NOT CREATED "); test.log(LogStatus.FAIL, "Private Site " + siteName + "IS NOT CREATED "); LOGGER.info("Expected Results : " + expectedResult); test.log(LogStatus.INFO, "Expected Results : " + expectedResult); LOGGER.info("Current Test Results : " + siteErrorNotification); test.log(LogStatus.FAIL, "Current Test Results : " + "<font color=red>" + siteErrorNotification + "<font>"); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "89" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "89" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } } LOGGER.info("CHECK WHETHER " + siteName + " IS CREATED OR NOT"); test.log(LogStatus.INFO, "CHECK WHETHER " + siteName + " IS CREATED OR NOT"); LOGGER.info("CHECK WHETHER " + siteName + " IS DISPLAY IN SITES LIST"); test.log(LogStatus.INFO, "CHECK WHETHER " + siteName + " IS DISPLAY IN SITES LIST"); LOGGER.info("Click \"Sites\""); test.log(LogStatus.INFO, "Click \"Sites\""); LOGGER.info("Click \"Site Finder\""); test.log(LogStatus.INFO, "Click \"Site Finder\""); LOGGER.info("Search sitename"); test.log(LogStatus.INFO, "Search sitename"); SearchObjects searchSite = new SearchObjects(driver); searchSite.searchSite(siteName, className, screenShotName); if (Element.isElementPresent(driver, By.xpath("//Span[text()='No sites found']"))) { LOGGER.info("Message display as \"No sites found\""); test.log(LogStatus.INFO, "Message display as \"No sites found\""); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "90" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "90" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { if (Element.isTextPresentInListForSite( driver.findElements( By.xpath("//tbody//tr//td//div//h3//a[contains(., '" + siteName + "')]")), siteName)) { LOGGER.info("Site is Display in \"Site Search\""); test.log(LogStatus.PASS, "<font color=green>Site is Display in \"Site Search\"<font>"); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "91" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "91" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { LOGGER.info("Site IS NOT Display in \"Site Search\""); test.log(LogStatus.FAIL, "<font color=red>Site is NOT Display in \"Site Search\"<font>"); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "92" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "92" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } } } loginPage.logout(); LOGGER.info("Test case b_createSite executed"); test.log(LogStatus.INFO, "Test case b_createSite executed"); extent.endTest(test); extent.flush(); } /** * * @Test Upload Document * @return * * @throws Exception InterruptedException, IOException */ @Test public void c_uploadDocument() throws InterruptedException, IOException { ExtentTest test = extent.startTest("c_uploadDocument", "Upload Document and Validate as Admin in the Private Site"); driver = TestCaseProperties.driverType("Chrome", "WINDOWS"); //Set the upper left corner of the screen starting point driver.manage().window().setPosition(new Point(0, 0)); //define screen size java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); // define desired size Dimension maxWindowSize = new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight()); // Maximize the browser window according to your system's current resolution(set desired size) driver.manage().window().setSize(maxWindowSize); LOGGER.info("Test case c_uploadDocument started execution"); test.log(LogStatus.INFO, "Test case c_uploadDocument started execution"); driver.get(TestCaseProperties.LOGIN_SCREEN_URL); LoginPage loginPage = new LoginPage(driver); LOGGER.info("Accessing the Login Page"); test.log(LogStatus.INFO, "Accessing the Login Page"); //Login as the Admin LOGGER.info("Login As Admin"); test.log(LogStatus.INFO, "Login As Admin"); loginPage.loginAsAdmin(className, screenShotName); Thread.sleep(3000); SearchObjects search = new SearchObjects(driver); //Search for the Site LOGGER.info("Click \"Search Finder\""); test.log(LogStatus.INFO, "Click \"Search Finder\""); LOGGER.info("Search Site \"" + siteName + "\""); test.log(LogStatus.INFO, "Search Site \"" + siteName + "\""); search.searchSite(siteName, className, screenShotName); //Clicks on the Site Link LOGGER.info("Navigate to the " + siteName); test.log(LogStatus.INFO, "Navigate to the " + siteName); Link siteLink = new Link(driver, By.xpath("//h3[@class='sitename']/a[text()='" + siteName + "']")); siteLink.click(); // Element.takescreenshot(driver, className, screenShotName); Thread.sleep(3000); //UploadDocument LOGGER.info("Upload the Document : " + documentName); test.log(LogStatus.INFO, "Upload the Document : " + documentName); test.log(LogStatus.INFO, "Navigate To DocumentLibrary"); test.log(LogStatus.INFO, "Click \"Upload Document\""); test.log(LogStatus.INFO, "Select the file \"" + documentName + "\""); CreateObjects upload = new CreateObjects(driver); upload.uploadDocument(documentName, className, screenShotName); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "93" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "93" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); TestCaseProperties.closeDriver(driver); //loginPage.logout(); LOGGER.info("Test case c_uploadDocument executed"); test.log(LogStatus.INFO, "Test case c_uploadDocument executed"); extent.endTest(test); extent.flush(); /** * * @Test Check whether Document is uploaded or not * @return * * @throws Exception InterruptedException, IOException */ } @Test public void d_verifyUploadDocument() throws InterruptedException, IOException { ExtentTest test = extent.startTest("d_verifyUploadDocument", "Verify the upload Document as Admin in the Private Site"); driver = TestCaseProperties.driverType("Chrome", "WINDOWS"); //Set the upper left corner of the screen starting point driver.manage().window().setPosition(new Point(0, 0)); //define screen size java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); // define desired size Dimension maxWindowSize = new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight()); // Maximize the browser window according to your system's current resolution(set desired size) driver.manage().window().setSize(maxWindowSize); LOGGER.info("Test case d_verifyUploadDocument started execution"); test.log(LogStatus.INFO, "Test case d_verifyUploadDocument started execution"); //UploadDocument LOGGER.info("Verify whether document " + documentName + " uploaded or not"); test.log(LogStatus.INFO, "Verify whether document " + documentName + " uploaded or not"); driver.get(TestCaseProperties.LOGIN_SCREEN_URL); LOGGER.info("Accessing the Login Page"); test.log(LogStatus.INFO, "Accessing the Login Page"); //Login as the Admin LOGGER.info("Login As Admin"); test.log(LogStatus.INFO, "Login As Admin"); LoginPage loginPage = new LoginPage(driver); loginPage.loginAsAdmin(className, screenShotName); SearchObjects search = new SearchObjects(driver); //Search for the Site LOGGER.info("Click \"Search Finder\""); test.log(LogStatus.INFO, "Click \"Search Finder\""); LOGGER.info("Search Site \"" + siteName + "\""); test.log(LogStatus.INFO, "Search Site \"" + siteName + "\""); search.searchSite(siteName, className, screenShotName); //Clicks on the Site Link LOGGER.info("Navigate to the " + siteName); test.log(LogStatus.INFO, "Navigate to the " + siteName); Link siteLink = new Link(driver, By.xpath("//h3[@class='sitename']/a[text()='" + siteName + "']")); siteLink.click(); // Element.takescreenshot(driver, className, screenShotName+"siteName"); Thread.sleep(3000); //Navigate to the Document Library LOGGER.info("Navigate To DocumentLibrary"); test.log(LogStatus.INFO, "Navigate To DocumentLibrary"); NavigateToPage navigate = new NavigateToPage(driver); navigate.goToDocLib(); Thread.sleep(3000); Element currentResult1 = new Element(driver, By.xpath("//h3[@class='filename']//span//a[contains(., " + documentName + ")]")); //Verify whether the uploaded file is available in the Document Library if (Button.isElementPresent(driver, By.xpath("//h3[@class='filename']//span//a[contains(., " + documentName + ")]"))) { //Expected Result LOGGER.info("Expected Results : " + documentName); test.log(LogStatus.INFO, "Expected Results : " + documentName); //Current Result LOGGER.info("Current Test Results : " + currentResult1.getWebElement().getText()); test.log(LogStatus.INFO, "Current Test Results : " + currentResult1.getWebElement().getText()); test.log(LogStatus.PASS, "The User has created the " + documentName + " successfully."); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "94" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "94" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { //Expected Result LOGGER.info("Expected Results : " + documentName); test.log(LogStatus.INFO, "Expected Results : " + documentName); //Current Result LOGGER.info("Current Test Results : " + currentResult1.getWebElement().getText()); test.log(LogStatus.INFO, "Current Test Results : " + currentResult1.getWebElement().getText()); test.log(LogStatus.FAIL, "The User has not created the " + documentName + " successfully."); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "95" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "95" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } loginPage.logout(); LOGGER.info("Test case d_verifyUploadDocument executed"); test.log(LogStatus.INFO, "Test case d_verifyUploadDocument executed"); extent.endTest(test); extent.flush(); } /** * * @Test Assign the user/Group to role to manage[Document Level] * @return * * @throws Exception InterruptedException, IOException */ @Test public void e_managePermission() throws InterruptedException, IOException { ExtentTest test = extent.startTest("e_managePermission", "Verify the upload Document as Admin in the Private Site"); driver = TestCaseProperties.driverType("Chrome", "WINDOWS"); //Set the upper left corner of the screen starting point driver.manage().window().setPosition(new Point(0, 0)); //define screen size java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); // define desired size Dimension maxWindowSize = new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight()); // Maximize the browser window according to your system's current resolution(set desired size) driver.manage().window().setSize(maxWindowSize); LOGGER.info("Test case e_managePermission started execution"); test.log(LogStatus.INFO, "Test case e_managePermission started execution"); driver.get(TestCaseProperties.LOGIN_SCREEN_URL); LOGGER.info("Accessing the Login Page"); test.log(LogStatus.INFO, "Accessing the Login Page"); //Login as the Admin LOGGER.info("Login As Admin"); test.log(LogStatus.INFO, "Login As Admin"); LoginPage loginPage = new LoginPage(driver); loginPage.loginAsAdmin(className, screenShotName); LOGGER.info("Give manage permission for document level"); test.log(LogStatus.INFO, "Give manage permission for document level"); test.log(LogStatus.INFO, "Click \"Search Finder\""); test.log(LogStatus.INFO, "Search Site \"" + siteName + "\""); test.log(LogStatus.INFO, "Navigate to the " + siteName); test.log(LogStatus.INFO, "Navigate To DocumentLibrary"); test.log(LogStatus.INFO, "Click Document"); test.log(LogStatus.INFO, "Click \"Manage Permissison\""); test.log(LogStatus.INFO, "Click \"Inheritence Permission\""); test.log(LogStatus.INFO, "Click \"Yes\" to remove inheritence"); test.log(LogStatus.INFO, "Click \"Add User/Group\" to add user/group"); test.log(LogStatus.INFO, "Search User"); test.log(LogStatus.INFO, "Click \"Search\""); test.log(LogStatus.INFO, "Click \"Add\" next to user"); test.log(LogStatus.INFO, "Set the permission"); test.log(LogStatus.INFO, "Click \"SAVE\""); CreateObjects managePermission = new CreateObjects(driver); managePermission.managePermission(siteName, documentName, userName, roleName, className, screenShotName); Thread.sleep(5000); WebDriver augmentedDriver12 = new Augmenter().augment(driver); File screenshot12 = ((TakesScreenshot) augmentedDriver12).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot12, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "new" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "new" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); loginPage.logout(); LOGGER.info("CHECK THE PERMISSION LEVEL"); test.log(LogStatus.INFO, "CHECK THE PERMISSION LEVEL"); LOGGER.info("Accessing the Login Page again"); test.log(LogStatus.INFO, "Accessing the Login Page again"); //Login as the Admin LOGGER.info("Login As Admin"); test.log(LogStatus.INFO, "Login As Admin"); LoginPage loginPage1 = new LoginPage(driver); loginPage1.loginAsAdmin(className, screenShotName); SearchObjects search = new SearchObjects(driver); //Search for the Site LOGGER.info("Click \"Search Finder\""); test.log(LogStatus.INFO, "Click \"Search Finder\""); LOGGER.info("Search Site \"" + siteName + "\""); test.log(LogStatus.INFO, "Search Site \"" + siteName + "\""); search.searchSite(siteName, className, screenShotName); //Clicks on the Site Link LOGGER.info("Navigate to the " + siteName); test.log(LogStatus.INFO, "Navigate to the " + siteName); Link siteLink = new Link(driver, By.xpath("//h3[@class='sitename']/a[text()='" + siteName + "']")); siteLink.click(); Thread.sleep(3000); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "96" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "96" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); //Navigate to the Document Library LOGGER.info("Navigate To DocumentLibrary"); test.log(LogStatus.INFO, "Navigate To DocumentLibrary"); NavigateToPage navigate = new NavigateToPage(driver); navigate.goToDocLib(); Thread.sleep(3000); //click the document LOGGER.info("Click Document"); test.log(LogStatus.INFO, "Click Document"); Link document = new Link(driver, By.xpath("//span/a[text()='" + documentName + "']")); document.click(); Thread.sleep(7000); //click manage Permisison LOGGER.info("Click \"Manage Permissison\""); test.log(LogStatus.INFO, "Click \"Manage Permissison\""); Span manage = new Span(driver, By.xpath("//span[contains(., 'Manage Permissions')]")); manage.click(); Element.waitForLoad(driver); Thread.sleep(5000); if (Element.isElementPresent(driver, By.xpath("//div[text()='" + userName + "']/ancestor::td/following-sibling::td[1]//button[text()='" + roleName + "']"))) { LOGGER.info("Successfully user " + userName + " added to role " + roleName + " in manage Permission"); test.log(LogStatus.PASS, "Successfully user " + userName + " added to role " + roleName + " in manage Permission"); WebDriver augmentedDriver3 = new Augmenter().augment(driver); File screenshot3 = ((TakesScreenshot) augmentedDriver3).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot3, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "98" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "98" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { LOGGER.info("User " + userName + " IS NOT added to role " + roleName + " in manage Permission"); test.log(LogStatus.FAIL, "User " + userName + " IS NOT added to role " + roleName + " in manage Permission"); WebDriver augmentedDriver4 = new Augmenter().augment(driver); File screenshot4 = ((TakesScreenshot) augmentedDriver4).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot4, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "99" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "99" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } loginPage1.logout(); LOGGER.info("Test case e_managePermission executed"); test.log(LogStatus.INFO, "Test case e_managePermission executed"); extent.endTest(test); extent.flush(); } /** * * @Test Delete the Document * @return * * @throws Exception InterruptedException, IOException */ @Test public void f_deleteDocument() throws InterruptedException, IOException { ExtentTest test = extent.startTest("f_deleteDocument", "Folder Creation and Validation as Admin in the Private Site"); driver = TestCaseProperties.driverType("Chrome", "WINDOWS"); //Set the upper left corner of the screen starting point driver.manage().window().setPosition(new Point(0, 0)); //define screen size java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); // define desired size Dimension maxWindowSize = new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight()); // Maximize the browser window according to your system's current resolution(set desired size) driver.manage().window().setSize(maxWindowSize); LOGGER.info("Test case f_deleteDocument started execution"); test.log(LogStatus.INFO, "Test case f_deleteDocument started execution"); driver.get(TestCaseProperties.LOGIN_SCREEN_URL); LoginPage loginPage = new LoginPage(driver); LOGGER.info("Accessing the Login Page"); test.log(LogStatus.INFO, "Accessing the Login Page"); //Login as the Admin LOGGER.info("Login As Admin"); test.log(LogStatus.INFO, "Login As Admin"); loginPage.loginAsAdmin(className, screenShotName); Thread.sleep(3000); SearchObjects search = new SearchObjects(driver); //Search for the Site LOGGER.info("Click \"Search Finder\""); test.log(LogStatus.INFO, "Click \"Search Finder\""); LOGGER.info("Search Site \"" + siteName + "\""); test.log(LogStatus.INFO, "Search Site \"" + siteName + "\""); search.searchSite(siteName, className, screenShotName); //Clicks on the Site Link LOGGER.info("Navigate to the " + siteName); test.log(LogStatus.INFO, "Navigate to the " + siteName); Link siteLink = new Link(driver, By.xpath("//h3[@class='sitename']/a[text()='" + siteName + "']")); siteLink.click(); // Element.takescreenshot(driver, className, screenShotName); Thread.sleep(3000); //Delete Folder LOGGER.info("Delete the Document : " + documentName); test.log(LogStatus.INFO, "Delete the Document : " + documentName); test.log(LogStatus.INFO, "Navigate To DocumentLibrary"); test.log(LogStatus.INFO, "Select Document"); test.log(LogStatus.INFO, "Click \"Selected Items\""); test.log(LogStatus.INFO, "Click \"Delete\" Button"); test.log(LogStatus.INFO, "Click \"Delete Confirmation\" Button"); test.log(LogStatus.INFO, "Login as Admin to delete Document in TrashCan"); test.log(LogStatus.INFO, "Click \"My Profile\""); test.log(LogStatus.INFO, "Place DocumentName"); test.log(LogStatus.INFO, "Click \"Search\" Button"); test.log(LogStatus.INFO, "Check the patucular DocumentName"); test.log(LogStatus.INFO, "Click \"Selected Item\" Button"); test.log(LogStatus.INFO, "Click \"Delete\" Button"); test.log(LogStatus.INFO, "Click \"OK\" Button"); test.log(LogStatus.INFO, "Click \"OK confirmation\" Button"); RemoveObjects delete = new RemoveObjects(driver); delete.deleteDocument(documentName, className, screenShotName); Thread.sleep(3000); WebDriver augmentedDriver2 = new Augmenter().augment(driver); File screenshot2 = ((TakesScreenshot) augmentedDriver2).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot2, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "100" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "100" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); loginPage.logout(); //--- Folder Validation LOGGER.info("Accessing the Login Page Again"); test.log(LogStatus.INFO, "Accessing the Login Page Again"); //Login as the Admin LOGGER.info("Login As Admin"); test.log(LogStatus.INFO, "Login As Admin"); LoginPage loginPage1 = new LoginPage(driver); loginPage1.loginAsAdmin(className, screenShotName); NavigateToPage navigateTo = new NavigateToPage(driver); LOGGER.info("CHECK WHETHER DOCUMENT\" " + documentName + " \"IS DELETED OR NOT"); test.log(LogStatus.INFO, "CHECK WHETHER DOCUMENT\" " + documentName + " \"IS DELETED OR NOT"); navigateTo.goToHome(); LOGGER.error("Click \"My Profile\" Again"); test.log(LogStatus.INFO, "Click \"My Profile\" Again"); navigateTo.goToUserTrashCan(className, screenShotName + "deletconfirmDOC123"); LOGGER.info("Place DocumentUrl"); test.log(LogStatus.INFO, "Place DocumentUrl"); TextField textField = new TextField(driver, By.id("template_x002e_user-trashcan_x002e_user-trashcan_x0023_default-search-text")); textField.clearText(); textField.enterText(documentName); LOGGER.info("Click \"Search\" Button"); test.log(LogStatus.INFO, "Click \"Search\" Button"); Button searchButton = new Button(driver, By.xpath("//button[text()='Search']")); searchButton.click(); Thread.sleep(2000); WebDriver augmentedDriver3 = new Augmenter().augment(driver); File screenshot3 = ((TakesScreenshot) augmentedDriver3).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot3, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "101" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "101" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); //CheckBox checkbox=new CheckBox(driver, By.xpath("//div[@class='name'][text()='"+item+"']/ancestor::td[1]/preceding-sibling::td[2]//input")); //checkbox.click(); LOGGER.info("Check the patucular docUrl"); test.log(LogStatus.INFO, "Check the patucular docUrl"); if (Element.isElementPresent(driver, By.xpath("//tbody[@class='yui-dt-message']//tr//td//div"))) { LOGGER.info(documentName + " Document IS DELETED SUCCESSFULLY"); test.log(LogStatus.PASS, documentName + " Document IS DELETED SUCCESSFULLY"); WebDriver augmentedDriver4 = new Augmenter().augment(driver); File screenshot4 = ((TakesScreenshot) augmentedDriver4).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot4, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "102" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "102" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { Element.waitUntilElementPresent(driver, By.xpath("//div//div//table//tbody//tr[contains(.,'" + documentName + "')]//td//div")); java.util.List<WebElement> myList = driver.findElements( By.xpath("//div//div//table//tbody//tr[contains(.,'" + documentName + "')]//td//div")); for (int i = 0; i < myList.size(); i++) { if (myList.get(i).getText().equals(documentName)) { Thread.sleep(2000); LOGGER.info(documentName + "Document IS NOT DELETED"); test.log(LogStatus.FAIL, documentName + " Document IS NOT DELETED"); WebDriver augmentedDriver4 = new Augmenter().augment(driver); File screenshot4 = ((TakesScreenshot) augmentedDriver4).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot4, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "103" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "103" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { LOGGER.info(documentName + " Document IS DELETED SUCCESSFULLY"); test.log(LogStatus.PASS, documentName + "Document IS DELETED SUCCESSFULLY"); WebDriver augmentedDriver4 = new Augmenter().augment(driver); File screenshot4 = ((TakesScreenshot) augmentedDriver4).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot4, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "104" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "104" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } } } loginPage1.logout(); LOGGER.info("Test case f_deleteDocument executed"); test.log(LogStatus.INFO, "Test case f_deleteDocument executed"); extent.endTest(test); extent.flush(); } /** * * @Test DeleteSite * @return * * @throws Exception InterruptedException, IOException */ @Test public void g_deleteSite() throws InterruptedException, IOException { LOGGER.info(TestCaseProperties.TEXT_TEST_EXECUTING, "Delete site called \" " + siteName + " \" "); //Extent Report Start Configuration(testCaseName,Definition of testCase) ExtentTest test = extent.startTest("g_deleteSite", "Delete site called \" " + siteName + " \" "); //Set the DriverType(BrowserName,Platform) driver = TestCaseProperties.driverType("Chrome", "WINDOWS"); // Set the upper left corner of the screen starting point driver.manage().window().setPosition(new Point(0, 0)); // define screen size java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); // define desired size Dimension maxWindowSize = new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight()); // Maximize the browser window according to your system's current // resolution(set desired size) driver.manage().window().setSize(maxWindowSize); //Get LoginScreen_URl from TestcaseProperties Values driver.get(TestCaseProperties.LOGIN_SCREEN_URL); LOGGER.info("Test case g_deleteSite started executing"); test.log(LogStatus.INFO, "Test case g_deleteSite started executing"); LOGGER.info("Accessing the Login Page"); test.log(LogStatus.INFO, "Accessing the Login Page"); LOGGER.info("Login as admin"); test.log(LogStatus.INFO, "Login as admin"); LoginPage loginPage = new LoginPage(driver); loginPage.loginAsAdmin(className, screenShotName); LOGGER.info("Check the site,if site exist Delet the user"); test.log(LogStatus.INFO, "Check the site,if site exist Delete the user"); test.log(LogStatus.INFO, "Search the site"); test.log(LogStatus.INFO, "Click \"Delete\" Button,next to site\"" + siteName + "\""); test.log(LogStatus.INFO, "Click \"Delete\" Button,for delete confirmation"); test.log(LogStatus.INFO, "Login as Admin to delete Site in TrashCan"); test.log(LogStatus.INFO, "Click \"My Profile\""); test.log(LogStatus.INFO, "Place siteUrl"); test.log(LogStatus.INFO, "Click \"Search\" Button"); test.log(LogStatus.INFO, "Check the patucular siteUrl"); test.log(LogStatus.INFO, "Click \"Selected Item\" Button"); test.log(LogStatus.INFO, "Click \"Delete\" Button"); test.log(LogStatus.INFO, "Click \"OK\" Button"); test.log(LogStatus.INFO, "Click \"OK confirmation\" Button"); RemoveObjects deleteSite = new RemoveObjects(driver); deleteSite.deleteSite(siteName, siteId, className, screenShotName); LOGGER.info("CHECK WHETHER SITE\" " + siteName + " \"IS DELETED OR NOT"); test.log(LogStatus.INFO, "CHECK WHETHER SITE\" " + siteName + " \"IS DELETED OR NOT"); NavigateToPage navigateTo = new NavigateToPage(driver); navigateTo.goToHome(); LOGGER.error("Click \"My Profile\" Again"); test.log(LogStatus.INFO, "Click \"My Profile\" Again"); test.log(LogStatus.INFO, "Accessing trashcan Page"); navigateTo.goToUserTrashCan(className, screenShotName + "deletconfirm1"); LOGGER.info("Place siteUrl"); test.log(LogStatus.INFO, "Place siteUrl"); TextField textField = new TextField(driver, By.id("template_x002e_user-trashcan_x002e_user-trashcan_x0023_default-search-text")); textField.clearText(); textField.enterText(siteId); LOGGER.info("Click \"Search\" Button"); test.log(LogStatus.INFO, "Click \"Search\" Button"); Button searchButton = new Button(driver, By.xpath("//button[text()='Search']")); searchButton.click(); Thread.sleep(2000); WebDriver augmentedDriver1 = new Augmenter().augment(driver); File screenshot1 = ((TakesScreenshot) augmentedDriver1).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot1, new File( TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "105" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "105" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); //Element.takescreenshot(driver, className, screenShotName+"deleteConfirmation"); //CheckBox checkbox=new CheckBox(driver, By.xpath("//div[@class='name'][text()='"+item+"']/ancestor::td[1]/preceding-sibling::td[2]//input")); //checkbox.click(); LOGGER.info("Check the patucular siteUrl"); test.log(LogStatus.INFO, "Check the patucular siteUrl"); if (Element.isElementPresent(driver, By.xpath("//tbody[@class='yui-dt-message']//tr//td//div"))) { LOGGER.info(siteName + " SITE IS DELETED SUCCESSFULLY"); test.log(LogStatus.PASS, siteName + " SITE IS DELETED SUCCESSFULLY"); WebDriver augmentedDriver2 = new Augmenter().augment(driver); File screenshot2 = ((TakesScreenshot) augmentedDriver2).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot2, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "106" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "106" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { Element.waitUntilElementPresent(driver, By.xpath("//div//div//table//tbody//tr[contains(.,'" + siteId + "')]//td//div")); java.util.List<WebElement> myList = driver .findElements(By.xpath("//div//div//table//tbody//tr[contains(.,'" + siteId + "')]//td//div")); for (int i = 0; i < myList.size(); i++) { if (myList.get(i).getText().equals(siteId)) { Thread.sleep(2000); LOGGER.info(siteName + "SITE IS NOT DELETED"); test.log(LogStatus.FAIL, siteName + " SITE IS NOT DELETED"); WebDriver augmentedDriver2 = new Augmenter().augment(driver); File screenshot2 = ((TakesScreenshot) augmentedDriver2).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot2, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "107" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "107" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } else { LOGGER.info(siteName + " SITE IS DELETED SUCCESSFULLY"); test.log(LogStatus.PASS, siteName + "SITE IS DELETED SUCCESSFULLY"); WebDriver augmentedDriver2 = new Augmenter().augment(driver); File screenshot2 = ((TakesScreenshot) augmentedDriver2).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot2, new File(TestCaseProperties.REPORT_TEST_PATH_CHROME + className + "/" + screenShotName + "108" + ".jpg")); test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("./" + className + "/" + screenShotName + "108" + ".jpg")); System.out.println("Screenshot Taken Successfully!!!!"); } } } loginPage.logout(); LOGGER.info("Test case g_deleteSite executed"); test.log(LogStatus.INFO, "Test case g_deleteSite executed"); extent.endTest(test); extent.flush(); } }