Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/test/java/com/amuselabs/test/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);

}

}
15 changes: 15 additions & 0 deletions src/test/java/com/amuselabs/test/TestSuite_CorrespondentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/amuselabs/test/TestSuite_LabelsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand Down
8 changes: 7 additions & 1 deletion src/test/java/com/amuselabs/test/TestSuite_LexiconTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.


Expand Down Expand Up @@ -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()
{
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/USER_INTERFACE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down