diff --git a/src/test/java/com/amuselabs/test/Helper.java b/src/test/java/com/amuselabs/test/Helper.java index 644282043..6298e61d9 100644 --- a/src/test/java/com/amuselabs/test/Helper.java +++ b/src/test/java/com/amuselabs/test/Helper.java @@ -4,6 +4,10 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; +import java.io.File; +import org.apache.commons.io.FileUtils; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.TakesScreenshot; import java.io.File; import java.io.FileInputStream; @@ -331,6 +335,22 @@ public String get_text_of_entire_mail_opened() { String body = e.getText(); return body; } + + //This clicks the download button on the correspondents page + public void click_on_download_correspondent() { + String download_correspondents = TestSuite_CorrespondentsTest.user_interface.getProperty("correspondents_download"); + WebElement e = driver.findElement(By.cssSelector(download_correspondents)); + e.click(); + waitFor(5); + } + + //This clicks the ok button on the downloads pop up of thecorrespondents page + public boolean get_download_correspondents() { + String correspodents_downloads_ok_button = TestSuite_CorrespondentsTest.user_interface.getProperty("correspodents_downloads_ok_button"); + WebElement e = driver.findElement(By.xpath(correspodents_downloads_ok_button)); + return (e.isEnabled()); + } + //HELPER METHOD FOR COUNTING NUMBER OF CONTACTS IN ANY PAGE public int countNumberOfContactsIn_a_Page() { @@ -739,4 +759,24 @@ public int number_of_messages_displayed_in_front_of_Lexicon() { int n = Integer.parseInt(e1.getText()); return n; } + + public void takeSnapShot(String fileWithPath) throws IOException { + + //Convert web driver object to TakeScreenshot + TakesScreenshot scrShot =((TakesScreenshot)driver); + + //Call getScreenshotAs method to create image file + File SrcFile=scrShot.getScreenshotAs(OutputType.FILE); + + File file = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); + + //Move image file to new destination + File DestFile=new File(fileWithPath); + + //Copy file at destination + + FileUtils.copyFile(SrcFile, DestFile); + + } + } diff --git a/src/test/java/com/amuselabs/test/TestSuite_CorrespondentsTest.java b/src/test/java/com/amuselabs/test/TestSuite_CorrespondentsTest.java index a1268e484..661707a72 100644 --- a/src/test/java/com/amuselabs/test/TestSuite_CorrespondentsTest.java +++ b/src/test/java/com/amuselabs/test/TestSuite_CorrespondentsTest.java @@ -3,6 +3,7 @@ import org.openqa.selenium.NoSuchElementException; import org.opentest4j.AssertionFailedError; +import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Properties; @@ -208,6 +209,20 @@ public void test_01_Sent_and_Received() //this test case calculates the sum of System.out.println("Number of messages opened="+number_of_messages_opened); } } + + @Test + public void correspondents_download() { + helper.click_on_download_correspondent(); + boolean result = helper.get_download_correspondents(); + assertTrue(result); + + } + + @Test + public void screenshot() throws IOException { + helper.takeSnapShot("Correspondents_screenshot.png"); + } + @AfterEach public void post_Set() { diff --git a/src/test/java/com/amuselabs/test/TestSuite_LabelsTest.java b/src/test/java/com/amuselabs/test/TestSuite_LabelsTest.java index f6b04207e..49da1eb78 100644 --- a/src/test/java/com/amuselabs/test/TestSuite_LabelsTest.java +++ b/src/test/java/com/amuselabs/test/TestSuite_LabelsTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; import org.opentest4j.AssertionFailedError; +import java.io.IOException; import java.io.InputStream; import java.util.Properties; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -156,6 +157,12 @@ public void test_04_Correct_number_of_mails_labelled() //this test case extracts } } } + + @Test + public void screenshot() throws IOException { + helper.takeSnapShot("Labels_screenshot.png"); + } + @AfterEach public void post_Set() { diff --git a/src/test/java/com/amuselabs/test/TestSuite_LexiconTest.java b/src/test/java/com/amuselabs/test/TestSuite_LexiconTest.java index 525061eb3..011c40764 100644 --- a/src/test/java/com/amuselabs/test/TestSuite_LexiconTest.java +++ b/src/test/java/com/amuselabs/test/TestSuite_LexiconTest.java @@ -7,6 +7,7 @@ import org.openqa.selenium.chrome.ChromeDriver; import org.opentest4j.AssertionFailedError; +import java.io.IOException; import java.io.InputStream; import java.util.Properties; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -17,7 +18,7 @@ //TEST CASES FOR LEXICONS public class TestSuite_LexiconTest { - Helper helper=new Helper("chrome"); + Helper helper=new Helper("firefox"); public static Properties lexicon = new Properties(); @BeforeAll @@ -51,4 +52,9 @@ public void test_05_Correct_number_of_messages_opened_onClick_Lexicon_category() System.out.println("Actual::" + actual_number_of_messages_opened_onClick_Lexicon_category); } } + + @Test + public void screenshot() throws IOException { + helper.takeSnapShot("Lexicon_screenshot.png"); + } } \ No newline at end of file diff --git a/src/test/java/com/amuselabs/test/TestSuite_Other_EntitiesTest.java b/src/test/java/com/amuselabs/test/TestSuite_Other_EntitiesTest.java index a499094e9..2bda07e2f 100644 --- a/src/test/java/com/amuselabs/test/TestSuite_Other_EntitiesTest.java +++ b/src/test/java/com/amuselabs/test/TestSuite_Other_EntitiesTest.java @@ -4,6 +4,7 @@ import org.openqa.selenium.chrome.ChromeDriver; import org.opentest4j.AssertionFailedError; +import java.io.IOException; import java.io.InputStream; import java.util.Properties; @@ -14,7 +15,7 @@ public class TestSuite_Other_EntitiesTest { - Helper helper=new Helper("chrome"); + Helper helper=new Helper("firefox"); public static Properties user_interface =new Properties(); @BeforeAll @@ -149,6 +150,12 @@ public void test_03_Sent_and_Received() //this test case checks whether the sum int number_of_messages_opened=helper.number_of_messages_opened_after_clicking_on_a_name(); assertTrue(sum>=number_of_messages_opened); } + + @Test + public void screenshot() throws IOException { + helper.takeSnapShot("Other_Entitites_screenshot.png"); + } + @AfterEach public void post_Set() { diff --git a/src/test/java/com/amuselabs/test/TestSuite_Person_EntitiesTest.java b/src/test/java/com/amuselabs/test/TestSuite_Person_EntitiesTest.java index dbee549ed..9dad8a322 100644 --- a/src/test/java/com/amuselabs/test/TestSuite_Person_EntitiesTest.java +++ b/src/test/java/com/amuselabs/test/TestSuite_Person_EntitiesTest.java @@ -6,6 +6,7 @@ import org.openqa.selenium.chrome.ChromeDriver; import org.opentest4j.AssertionFailedError; +import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.NoSuchElementException; @@ -19,7 +20,7 @@ public class TestSuite_Person_EntitiesTest { - Helper helper=new Helper("chrome"); + Helper helper=new Helper("firefox"); public static Properties user_interface =new Properties(); //user_interface variable corresponding to the Properties file for Person-Entities. @@ -215,6 +216,12 @@ public void test_02_Person_Entity_Name_highlighted_or_Not() //this test case ch System.out.println("The name "+name+" is highlighted "+count+" times"); } } + + @Test + public void screenshot() throws IOException { + helper.takeSnapShot("Person_Entties_screenshot.png"); + } + @AfterEach public void post_Set() { diff --git a/src/test/resources/USER_INTERFACE.properties b/src/test/resources/USER_INTERFACE.properties index 5dfb35696..742bcc4e9 100644 --- a/src/test/resources/USER_INTERFACE.properties +++ b/src/test/resources/USER_INTERFACE.properties @@ -14,6 +14,8 @@ data_in_CorrespondentsButton=#all-cards > div:nth-child(1) > a > p.cta-text-1 edit_correspondents=div.buttons_on_datatable:nth-child(2) #edit_correspondents=body > div:nth-child(5) > button:nth-child(2) text_of_entire_mail=#jog_contents +correspondents_download=div.buttons_on_datatable:nth-child(4) +correspodents_downloads_ok_button=/html/body/div[6]/div/div/div[3]/button