From 961b82bb863b4ba93efb664859ea903497e2d755 Mon Sep 17 00:00:00 2001 From: aissel Date: Thu, 5 Oct 2023 10:53:50 +0530 Subject: [PATCH] Second commit --- pom.xml | 207 +++++++++--------- src/test/java/TestScripts/Contacts_Count.java | 5 +- src/test/java/TestScripts/Discover_Count.java | 33 ++- .../TestScripts/Track_Interaction_Count.java | 41 +++- .../TestScripts/Track_Interaction_Export.java | 9 +- .../TestScripts/Track_Medinsght_Export.java | 7 +- .../TestScripts/Track_Medinsight_Count.java | 50 +++-- src/test/java/Utilities/ConfigReader.java | 32 +-- testng.xml | 2 +- 9 files changed, 226 insertions(+), 160 deletions(-) diff --git a/pom.xml b/pom.xml index 316009b..e728659 100644 --- a/pom.xml +++ b/pom.xml @@ -1,20 +1,22 @@ - - 4.0.0 - DCIM_Counts_Check - DCIM_Counts_Check - 0.0.1-SNAPSHOT - - - DCIM_Counts_Check - http://maven.apache.org - - + + 4.0.0 + DCIM_Counts_Check + DCIM_Counts_Check + 0.0.1-SNAPSHOT + + + DCIM_Counts_Check + http://maven.apache.org + + UTF-8 1.8 - 1.8 - 5.6.0 - 11 - src/test/java + 1.8 + 5.6.0 + 11 + src/test/java @@ -25,32 +27,26 @@ - + + junit junit - 4.11 + 4.12 test - - - io.github.bonigarcia - webdrivermanager - 5.5.3 - test - - - - io.cucumber - gherkin - 5.1.0 - - - - org.apache.poi - poi-ooxml - 3.9 - + + io.cucumber + gherkin + 5.1.0 + + + + + org.apache.poi + poi-ooxml + 3.9 + @@ -59,25 +55,26 @@ 1.5.5 - - org.apache.commons - commons-lang3 - 3.4 - + + org.apache.commons + commons-lang3 + 3.4 + + + + io.github.bonigarcia + webdrivermanager + 5.5.3 + test + - - io.github.bonigarcia - webdrivermanager - 5.5.3 - test - - com.sun.mail javax.mail 1.6.2 - + com.github.ralfstuckert.pdfbox-layout pdfbox2-layout @@ -85,7 +82,6 @@ - org.testng @@ -116,25 +112,26 @@ test - - - io.cucumber - cucumber-picocontainer - 4.8.1 - test - + + + io.cucumber + cucumber-picocontainer + 4.8.1 + test + - - - io.cucumber - cucumber-core - 4.8.1 - test - + + + io.cucumber + cucumber-core + 4.8.1 + test + - - + org.seleniumhq.selenium selenium-java @@ -142,7 +139,8 @@ - + com.aventstack extentreports-cucumber4-adapter @@ -167,47 +165,48 @@ 2.3.30 - - - org.apache.maven - maven-plugin-api - 3.8.3 - - + + + org.apache.maven + maven-plugin-api + 3.8.3 + + - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - true - true - C:\Program Files\Java\jdk1.8.0_202\bin\javac - 1.3 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18.1 - - - org.apache.maven.surefire - surefire-junit47 - 2.18.1 - - - -true - - -/home/aissel/git2/DCIM_Counts_Check/testng.xml - - - - + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + true + true + C:\Program Files\Java\jdk1.8.0_202\bin\javac + 1.3 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + org.apache.maven.surefire + surefire-junit47 + 2.18.1 + + + + true + + + /home/aissel/git4/testng.xml + + + + \ No newline at end of file diff --git a/src/test/java/TestScripts/Contacts_Count.java b/src/test/java/TestScripts/Contacts_Count.java index 4eeaa4f..dc99fb3 100644 --- a/src/test/java/TestScripts/Contacts_Count.java +++ b/src/test/java/TestScripts/Contacts_Count.java @@ -5,11 +5,14 @@ import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; +import org.testng.annotations.Test; + import Utilities.ConfigReader; import io.github.bonigarcia.wdm.WebDriverManager; public class Contacts_Count { + @Test public static void main(String[] args) throws InterruptedException { WebDriverManager.chromedriver().setup(); @@ -40,7 +43,7 @@ public class Contacts_Count System.out.println("Contacts: " + text); Thread.sleep(3000); driver.findElement(By.xpath("//p[@id='settings_menu ']")).click(); - driver.findElement(By.xpath("//body[1]/div[74]/div[2]/div[1]/div[1]/a[1]/div[1]/table[1]/tbody[1]/tr[1]/td[2]/a[1]")).click(); + driver.findElement(By.xpath("//a[@onclick='logoutOtherURLS()']")).click(); Thread.sleep(3000); } driver.quit(); diff --git a/src/test/java/TestScripts/Discover_Count.java b/src/test/java/TestScripts/Discover_Count.java index 2cd5064..90d8a31 100644 --- a/src/test/java/TestScripts/Discover_Count.java +++ b/src/test/java/TestScripts/Discover_Count.java @@ -9,6 +9,7 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import org.testng.annotations.Test; import org.testng.internal.BaseClassFinder; import Utilities.ConfigReader; @@ -17,16 +18,15 @@ import io.github.bonigarcia.wdm.WebDriverManager; public class Discover_Count { - String path = System.getProperty("user.dir"); - + @Test public static void main(String[] args) throws InterruptedException { WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); - ConfigReader config = new ConfigReader(); + ConfigReader config = new ConfigReader(); // Define the sets you want to use - //String[] sets = {"set1", "set2", "set3", "set4", "set5", "set6", "set7"}; - String[] sets = {"set1", "set4", "set5", "set6", "set7"}; + String[] sets = {"set1", "set2", "set4", "set5", "set6", "set7"}; + //String[] sets = {"set1", "set4", "set5", "set6", "set7"}; Thread.sleep(10000); for (String set : sets) { Thread.sleep(10000); @@ -46,12 +46,23 @@ public class Discover_Count Thread.sleep(5000); WebDriverWait wait = new WebDriverWait(driver, 60); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[normalize-space()='Reset']"))); - //wait.until(ExpectedConditions.titleContains("kolsByRankingPager_left")); - //JavascriptExecutor jse = (JavascriptExecutor) driver; - //jse.executeScript("window.scrollTo(0,document.body.scrollHeight)"); + + String text= driver.findElement(By.xpath("//div[@class='ui-paging-info']")).getText(); + System.out.println("Total Discover count: " + text); + Thread.sleep(3000); + driver.findElement(By.xpath("//p[@id='settings_menu ']")).click(); + driver.findElement(By.xpath("//a[@onclick='logoutOtherURLS()']")).click(); + Thread.sleep(3000); + } + driver.quit(); - //driver.findElement(By.xpath("//span[@class='ui-icon ui-icon-seek-end']")).click(); - try { + } +} + + + + + /* try { int totalRowCount = 0; boolean hasNextPage = true; @@ -92,6 +103,6 @@ public class Discover_Count driver.quit(); } -} +} */ diff --git a/src/test/java/TestScripts/Track_Interaction_Count.java b/src/test/java/TestScripts/Track_Interaction_Count.java index bfe7f3e..2144fd6 100644 --- a/src/test/java/TestScripts/Track_Interaction_Count.java +++ b/src/test/java/TestScripts/Track_Interaction_Count.java @@ -10,6 +10,7 @@ import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.Wait; import org.openqa.selenium.support.ui.WebDriverWait; +import org.testng.annotations.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -19,9 +20,10 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import Utilities.ConfigReader; import Utilities.readConfigFile; import io.github.bonigarcia.wdm.WebDriverManager; - + public class Track_Interaction_Count { + @Test public static void main(String[] args) throws InterruptedException { WebDriverManager.chromedriver().setup(); @@ -29,7 +31,7 @@ public class Track_Interaction_Count ConfigReader config = new ConfigReader(); // Define the sets you want to use String[] sets = {"set1", "set2", "set3", "set4", "set5", "set6", "set7"}; - + Thread.sleep(10000); for (String set : sets) { Thread.sleep(10000); @@ -52,11 +54,34 @@ public class Track_Interaction_Count driver.findElement(By.xpath("//div[@id='resetBttn']")).click(); Thread.sleep(3000); - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='wrapper']"))); - + WebDriverWait wait = new WebDriverWait(driver, 10); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='wrapper']"))); - try { + String text= driver.findElement(By.xpath("//div[@class='ui-paging-info']")).getText(); + System.out.println("Total Interactions count: " + text); + Thread.sleep(3000); + + } catch (NoSuchElementException e) { + // Handle the exception here (e.g., log, report, or take screenshots) + System.out.println("Element not found: " + e.getMessage()); + } + + driver.findElement(By.xpath("//p[@id='settings_menu ']")).click(); + driver.findElement(By.xpath("//a[@onclick='logoutOtherURLS()']")).click(); + Thread.sleep(3000); + + } + driver.quit(); + } +} + + + + + + + +/*try { int totalRowCount = 0; boolean hasNextPage = true; @@ -91,7 +116,7 @@ public class Track_Interaction_Count // Handle the exception here (e.g., log, report, or take screenshots) System.out.println("Element not found: " + e.getMessage()); } - + driver.findElement(By.xpath("//p[@id='settings_menu ']")).click(); driver.findElement(By.xpath("//a[@onclick='logoutOtherURLS()']")).click(); Thread.sleep(3000); @@ -99,5 +124,5 @@ public class Track_Interaction_Count } driver.quit(); } -} +}*/ diff --git a/src/test/java/TestScripts/Track_Interaction_Export.java b/src/test/java/TestScripts/Track_Interaction_Export.java index 9c8f1a2..a40f9d8 100644 --- a/src/test/java/TestScripts/Track_Interaction_Export.java +++ b/src/test/java/TestScripts/Track_Interaction_Export.java @@ -11,20 +11,22 @@ import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import Utilities.ConfigReader; import Utilities.readConfigFile; import io.github.bonigarcia.wdm.WebDriverManager; - + public class Track_Interaction_Export { + @Test public static void main(String[] args) throws InterruptedException { ChromeOptions options = new ChromeOptions(); // Set the download directory - options.addArguments("download.default_directory=/home/aissel/git4"); + options.addArguments("download.default_directory=" +System.getProperty("user.dir")); // Disable the download prompt options.setExperimentalOption("prefs", ImmutableMap.of("download.prompt_for_download", false, "download.directory_upgrade", true)); @@ -64,7 +66,8 @@ public class Track_Interaction_Export WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@data-original-title='Export Interaction Detail into Excel format']"))); - File downloadedFile = new File("/home/aissel/Git2/DICM_Count/exported_file.xlsx"); + //File downloadedFile = new File("/home/aissel/git4/exported_file.xlsx"); + File downloadedFile = new File(System.getProperty("user.dir")+"/exported_file.xlsx"); if (downloadedFile.exists()) { System.out.println("Downloaded file exists."); } else { diff --git a/src/test/java/TestScripts/Track_Medinsght_Export.java b/src/test/java/TestScripts/Track_Medinsght_Export.java index 6c2a45f..d18ae2d 100644 --- a/src/test/java/TestScripts/Track_Medinsght_Export.java +++ b/src/test/java/TestScripts/Track_Medinsght_Export.java @@ -12,6 +12,7 @@ import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; @@ -20,12 +21,14 @@ import io.github.bonigarcia.wdm.WebDriverManager; public class Track_Medinsght_Export { + @Test public static void main(String[] args) throws InterruptedException { ChromeOptions options = new ChromeOptions(); // Set the download directory - options.addArguments("download.default_directory=/home/aissel/git4"); + //options.addArguments("download.default_directory=/home/aissel/git4"); + options.addArguments("download.default_directory=" +System.getProperty("user.dir")); // Disable the download prompt options.setExperimentalOption("prefs", ImmutableMap.of("download.prompt_for_download", false, "download.directory_upgrade", true)); @@ -66,7 +69,7 @@ public class Track_Medinsght_Export WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='excelExportIcon sprite_iconSet tooltip-demo tooltop-left']"))); - File downloadedFile = new File("/home/aissel/Git2/DICM_Count/exported_file.xlsx"); + File downloadedFile = new File(System.getProperty("user.dir")+"/exported_file.xlsx"); if (downloadedFile.exists()) { System.out.println("Downloaded file exists."); } else { diff --git a/src/test/java/TestScripts/Track_Medinsight_Count.java b/src/test/java/TestScripts/Track_Medinsight_Count.java index 518e917..69b14e9 100644 --- a/src/test/java/TestScripts/Track_Medinsight_Count.java +++ b/src/test/java/TestScripts/Track_Medinsight_Count.java @@ -10,20 +10,22 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import org.testng.annotations.Test; import Utilities.ConfigReader; import Utilities.readConfigFile; import io.github.bonigarcia.wdm.WebDriverManager; - + public class Track_Medinsight_Count { + @Test public static void main(String[] args) throws InterruptedException { WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); ConfigReader config = new ConfigReader(); // Define the sets you want to use - String[] sets = {"set1", "set2", "set3", "set4", "set5", "set6"}; + String[] sets = {"set1", "set2", "set3", "set4", "set5", "set6", "set7"}; //String[] sets = {"set"}; Thread.sleep(10000); for (String set : sets) { @@ -44,14 +46,34 @@ public class Track_Medinsight_Count element.click(); Thread.sleep(3000); //driver.findElement(By.xpath("//div[@class='navLinkTrack sprite_iconSet ']")).click(); - driver.findElement(By.xpath("//label[@for='medical_insight']")).click(); - driver.findElement(By.xpath("//div[@id='resetBttn']")).click(); + driver.findElement(By.xpath("//label[@for='medical_insight']")).click(); + driver.findElement(By.xpath("//div[@id='resetBttn']")).click(); Thread.sleep(3000); - WebDriverWait wait = new WebDriverWait(driver, 10); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='wrapper']"))); - + WebDriverWait wait = new WebDriverWait(driver, 10); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='wrapper']"))); - try { + String text= driver.findElement(By.xpath("//div[@class='ui-paging-info']")).getText(); + System.out.println("Total MedInsight count: " + text); + Thread.sleep(3000); + + } catch (NoSuchElementException e) { + // Handle the exception here (e.g., log, report, or take screenshots) + System.out.println("Element not found: " + e.getMessage()); + } + + driver.findElement(By.xpath("//p[@id='settings_menu ']")).click(); + driver.findElement(By.xpath("//a[@onclick='logoutOtherURLS()']")).click(); + Thread.sleep(3000); + + } + driver.quit(); + } +} + + + + +/*try { int totalRowCount = 0; boolean hasNextPage = true; @@ -86,7 +108,7 @@ public class Track_Medinsight_Count // Handle the exception here (e.g., log, report, or take screenshots) System.out.println("Element not found: " + e.getMessage()); } - + driver.findElement(By.xpath("//p[@id='settings_menu ']")).click(); driver.findElement(By.xpath("//a[@onclick='logoutOtherURLS()']")).click(); Thread.sleep(3000); @@ -94,10 +116,10 @@ public class Track_Medinsight_Count } driver.quit(); } -} - - - - +} */ + + + + diff --git a/src/test/java/Utilities/ConfigReader.java b/src/test/java/Utilities/ConfigReader.java index dc4eb3c..3643c43 100644 --- a/src/test/java/Utilities/ConfigReader.java +++ b/src/test/java/Utilities/ConfigReader.java @@ -4,26 +4,26 @@ import java.io.IOException; import java.util.Properties; public class ConfigReader { - private Properties properties; + private Properties properties; - public ConfigReader() { - properties = new Properties(); - try { - FileInputStream fis = new FileInputStream("/home/aissel/git4/src/test/resources/browser-config.properties"); - properties.load(fis); - fis.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + public ConfigReader() { + properties = new Properties(); + try { + FileInputStream fis = new FileInputStream(System.getProperty("user.dir")+"/src/test/resources/browser-config.properties"); + properties.load(fis); + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } - public String getProperty(String setName, String key) { - // Combine the set name and key to get the property - return properties.getProperty(setName + "." + key); - } + public String getProperty(String setName, String key) { + // Combine the set name and key to get the property + return properties.getProperty(setName + "." + key); + } } - + diff --git a/testng.xml b/testng.xml index 7e8317c..20e9292 100644 --- a/testng.xml +++ b/testng.xml @@ -3,7 +3,7 @@ - +