From b4bf3e08ad6532480ae4c06327afa910d0286e7d Mon Sep 17 00:00:00 2001 From: aissel Date: Tue, 3 Oct 2023 14:47:23 +0530 Subject: [PATCH] First commit --- .classpath | 40 ++++ .gitignore | 1 + .project | 23 ++ .settings/org.eclipse.core.resources.prefs | 6 + .settings/org.eclipse.jdt.core.prefs | 8 + .settings/org.eclipse.m2e.core.prefs | 4 + pom.xml | 213 ++++++++++++++++++ src/test/java/TestScripts/Contacts_Count.java | 49 ++++ src/test/java/TestScripts/Discover_Count.java | 97 ++++++++ .../TestScripts/Track_Interaction_Count.java | 103 +++++++++ .../TestScripts/Track_Interaction_Export.java | 133 +++++++++++ .../TestScripts/Track_Medinsght_Export.java | 131 +++++++++++ .../TestScripts/Track_Medinsight_Count.java | 103 +++++++++ src/test/java/Utilities/ConfigReader.java | 29 +++ src/test/java/Utilities/readConfigFile.java | 69 ++++++ src/test/resources/browser-config.properties | 35 +++ testng.xml | 9 + 17 files changed, 1053 insertions(+) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 pom.xml create mode 100644 src/test/java/TestScripts/Contacts_Count.java create mode 100644 src/test/java/TestScripts/Discover_Count.java create mode 100644 src/test/java/TestScripts/Track_Interaction_Count.java create mode 100644 src/test/java/TestScripts/Track_Interaction_Export.java create mode 100644 src/test/java/TestScripts/Track_Medinsght_Export.java create mode 100644 src/test/java/TestScripts/Track_Medinsight_Count.java create mode 100644 src/test/java/Utilities/ConfigReader.java create mode 100644 src/test/java/Utilities/readConfigFile.java create mode 100644 src/test/resources/browser-config.properties create mode 100644 testng.xml diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..f0e9804 --- /dev/null +++ b/.classpath @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/.project b/.project new file mode 100644 index 0000000..176f13b --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + DCIM_Counts_Check + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..29abf99 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b5490a0 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..316009b --- /dev/null +++ b/pom.xml @@ -0,0 +1,213 @@ + + 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 + + + + + jitpack.io + https://jitpack.io + + + + + + junit + junit + 4.11 + test + + + + io.github.bonigarcia + webdrivermanager + 5.5.3 + test + + + + io.cucumber + gherkin + 5.1.0 + + + + + org.apache.poi + poi-ooxml + 3.9 + + + + + javax.mail + javax.mail-api + 1.5.5 + + + + org.apache.commons + commons-lang3 + 3.4 + + + + io.github.bonigarcia + webdrivermanager + 5.5.3 + test + + + + com.sun.mail + javax.mail + 1.6.2 + + + + com.github.ralfstuckert.pdfbox-layout + pdfbox2-layout + 0.8.6 + + + + + + + org.testng + testng + 6.14.3 + test + + + + com.apple + AppleJavaExtensions + 1.4 + + + + + io.cucumber + cucumber-java8 + 4.8.1 + + + + + + io.cucumber + cucumber-junit + 4.8.1 + test + + + + + io.cucumber + cucumber-picocontainer + 4.8.1 + test + + + + + io.cucumber + cucumber-core + 4.8.1 + test + + + + + + + org.seleniumhq.selenium + selenium-java + 3.141.59 + + + + + + com.aventstack + extentreports-cucumber4-adapter + 1.0.12 + + + io.cucumber + cucumber-java + + + io.cucumber + cucumber-core + + + + + + org.freemarker + + freemarker + + 2.3.30 + + + + + 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 + + + + + + \ No newline at end of file diff --git a/src/test/java/TestScripts/Contacts_Count.java b/src/test/java/TestScripts/Contacts_Count.java new file mode 100644 index 0000000..4eeaa4f --- /dev/null +++ b/src/test/java/TestScripts/Contacts_Count.java @@ -0,0 +1,49 @@ +package TestScripts; + +import java.util.concurrent.TimeUnit; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import Utilities.ConfigReader; +import io.github.bonigarcia.wdm.WebDriverManager; + +public class Contacts_Count +{ + 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", "set7"}; + Thread.sleep(10000); + for (String set : sets) { + Thread.sleep(10000); + String url = config.getProperty(set, "url"); + String username = config.getProperty(set, "username"); + String password = config.getProperty(set, "password"); + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + driver.get(url); + Thread.sleep(10000); + driver.findElement(By.xpath("//input[@id='username']")).sendKeys(username); + driver.findElement(By.xpath("//input[@id='password']")).sendKeys(password); + driver.findElement(By.xpath("//input[@id='kc-login']")).click(); + driver.findElement(By.xpath("//div[@class='navLinkMyKolsIn sprite_iconSet']")).click(); + System.out.println("URL: " + url); + System.out.println("Username: " + username); + String text= driver.findElement(By.xpath("//label[@id='countKolMsg']")).getText(); + 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(); + Thread.sleep(3000); + } + driver.quit(); + + } +} diff --git a/src/test/java/TestScripts/Discover_Count.java b/src/test/java/TestScripts/Discover_Count.java new file mode 100644 index 0000000..2cd5064 --- /dev/null +++ b/src/test/java/TestScripts/Discover_Count.java @@ -0,0 +1,97 @@ +package TestScripts; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +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.internal.BaseClassFinder; + +import Utilities.ConfigReader; +import Utilities.readConfigFile; +import io.github.bonigarcia.wdm.WebDriverManager; + +public class Discover_Count +{ + String path = System.getProperty("user.dir"); + + 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", "set7"}; + String[] sets = {"set1", "set4", "set5", "set6", "set7"}; + Thread.sleep(10000); + for (String set : sets) { + Thread.sleep(10000); + String url = config.getProperty(set, "url"); + String username = config.getProperty(set, "username"); + String password = config.getProperty(set, "password"); + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + driver.get(url); + driver.findElement(By.xpath("//input[@id='username']")).sendKeys(username); + driver.findElement(By.xpath("//input[@id='password']")).sendKeys(password); + driver.findElement(By.xpath("//input[@id='kc-login']")).click(); + System.out.println("URL: " + url); + System.out.println("Username: " + username); + + driver.findElement(By.xpath("//div[@class='navLinkIdentify sprite_iconSet']")).click(); + 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)"); + + //driver.findElement(By.xpath("//span[@class='ui-icon ui-icon-seek-end']")).click(); + try { + int totalRowCount = 0; + boolean hasNextPage = true; + + while (hasNextPage) { + // Find and count the rows on the current page + List rows = driver.findElements(By.xpath("//table[@id='kolsByRankingResultSet']/tbody/tr")); // Adjust the XPath to match your table structure + int Count = rows.size()-1; + Thread.sleep(3000); + // Exclude the header row if needed + if (Count > 0) { + totalRowCount += Count ; + System.out.println("Total Number of Disc_contacts : " + Count); + } + + // Check if there is a next page + WebElement nextPageButton = driver.findElement(By.xpath("//td[@id='next_kolsByRankingPager']")); // Adjust the XPath to match your pagination control + if (nextPageButton.getAttribute("class").contains("disabled")) { + hasNextPage = false; + } else { + // Click the "Next" button to navigate to the next page + nextPageButton.click(); + Thread.sleep(4000); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='gbox_kolsByRankingResultSet']"))); + } + } + + System.out.println("Total Discover count: " + totalRowCount); + } catch (Exception e) { + e.printStackTrace(); + } finally { + + } + Thread.sleep(4000); + driver.findElement(By.xpath("//p[@id='settings_menu ']")).click(); + driver.findElement(By.xpath("//a[@onclick='logoutOtherURLS()']")).click(); + Thread.sleep(3000); + } + driver.quit(); + } + +} + + diff --git a/src/test/java/TestScripts/Track_Interaction_Count.java b/src/test/java/TestScripts/Track_Interaction_Count.java new file mode 100644 index 0000000..bfe7f3e --- /dev/null +++ b/src/test/java/TestScripts/Track_Interaction_Count.java @@ -0,0 +1,103 @@ +package TestScripts; + +import java.util.List; +import java.util.concurrent.TimeUnit; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +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.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import Utilities.ConfigReader; +import Utilities.readConfigFile; +import io.github.bonigarcia.wdm.WebDriverManager; + +public class Track_Interaction_Count +{ + 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", "set7"}; + + Thread.sleep(10000); + for (String set : sets) { + Thread.sleep(10000); + String url = config.getProperty(set, "url"); + String username = config.getProperty(set, "username"); + String password = config.getProperty(set, "password"); + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + driver.get(url); + driver.findElement(By.xpath("//input[@id='username']")).sendKeys(username); + driver.findElement(By.xpath("//input[@id='password']")).sendKeys(password); + driver.findElement(By.xpath("//input[@id='kc-login']")).click(); + System.out.println("URL: " + url); + System.out.println("Username: " + username); + try { + WebElement element = driver.findElement(By.xpath("//div[@class='navLinkTrack sprite_iconSet ']")); + element.click(); + + //driver.findElement(By.xpath("//div[@class='navLinkTrack sprite_iconSet ']")).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']"))); + + + try { + int totalRowCount = 0; + boolean hasNextPage = true; + + while (hasNextPage) { + // Find and count the rows on the current page + List rows = driver.findElements(By.xpath("//table[@aria-labelledby='gbox_listInteractionsResultSet']/tbody/tr")); // Adjust the XPath to match your table structure + int Count = rows.size()-1; + Thread.sleep(5000); + // Exclude the header row if needed + if (Count > 1) { + totalRowCount += Count ; + System.out.println("Total Number of Interactions : " + Count); + } + + // Check if there is a next page + WebElement nextPageButton = driver.findElement(By.xpath("//td[@id='next_listInteractionsPage']")); // Adjust the XPath to match your pagination control + if (nextPageButton.getAttribute("class").contains("disabled")) { + hasNextPage = false; + } else { + // Click the "Next" button to navigate to the next page + nextPageButton.click(); + Thread.sleep(5000); + } + } + + System.out.println("Total Interactions count: " + totalRowCount); + } catch (Exception e) { + e.printStackTrace(); + } finally { + } + } 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(); + } +} + diff --git a/src/test/java/TestScripts/Track_Interaction_Export.java b/src/test/java/TestScripts/Track_Interaction_Export.java new file mode 100644 index 0000000..9c8f1a2 --- /dev/null +++ b/src/test/java/TestScripts/Track_Interaction_Export.java @@ -0,0 +1,133 @@ +package TestScripts; + +import java.io.File; +import java.util.concurrent.TimeUnit; + +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +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 com.google.common.collect.ImmutableMap; + +import Utilities.ConfigReader; +import Utilities.readConfigFile; +import io.github.bonigarcia.wdm.WebDriverManager; + +public class Track_Interaction_Export +{ + public static void main(String[] args) throws InterruptedException + { + ChromeOptions options = new ChromeOptions(); + // Set the download directory + options.addArguments("download.default_directory=/home/aissel/git4"); + // Disable the download prompt + options.setExperimentalOption("prefs", + ImmutableMap.of("download.prompt_for_download", false, "download.directory_upgrade", true)); + 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", "set7"}; + //String[] sets = {"set"}; + Thread.sleep(10000); + for (String set : sets) { + Thread.sleep(10000); + String url = config.getProperty(set, "url"); + String username = config.getProperty(set, "username"); + String password = config.getProperty(set, "password"); + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + driver.get(url); + driver.findElement(By.xpath("//input[@id='username']")).sendKeys(username); + driver.findElement(By.xpath("//input[@id='password']")).sendKeys(password); + driver.findElement(By.xpath("//input[@id='kc-login']")).click(); + System.out.println("URL: " + url); + System.out.println("Username: " + username); + + try { + WebElement element = driver.findElement(By.xpath("//div[@class='navLinkTrack sprite_iconSet ']")); + element.click(); + Thread.sleep(3000); + //driver.findElement(By.xpath("//div[@class='navLinkTrack sprite_iconSet ']")).click(); + driver.findElement(By.xpath("//div[@id='resetBttn']")).click(); + Thread.sleep(3000); + + WebElement downloadButton = driver.findElement(By.xpath("//a[@data-original-title='Export Interaction Detail into Excel format']")); + downloadButton.click(); + Thread.sleep(6000); + // Wait for the download to complete (adjust the timeout as needed) + 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"); + if (downloadedFile.exists()) { + System.out.println("Downloaded file exists."); + } else { + System.out.println("Downloaded file does not exist."); + } + + } 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(); + } + +} + + + /* + WebDriverManager.chromedriver().setup(); + WebDriver driver = new ChromeDriver(); + + readConfigFile Config= new readConfigFile(); + + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + driver.get(Config.getURL()); + driver.findElement(By.xpath("//input[@id='username']")).sendKeys(Config.getUSERNAME()); + driver.findElement(By.xpath("//input[@id='password']")).sendKeys(Config.getPASSWORD()); + driver.findElement(By.xpath("//input[@id='kc-login']")).click(); + driver.findElement(By.xpath("//div[@class='navLinkTrack sprite_iconSet ']")).click(); + driver.findElement(By.xpath("//div[@id='resetBttn']")).click(); + //driver.findElement(By.xpath(null)) + + + // Find and click the download link/button + WebElement downloadButton = driver.findElement(By.xpath("//a[@data-original-title='Export Interaction Detail into Excel format']")); + downloadButton.click(); + Thread.sleep(5000); + + // Wait for the download to complete (adjust the timeout as needed) + WebDriverWait wait = new WebDriverWait(driver, 30); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@data-original-title='Export Interaction Detail into Excel format']"))); + + // Verify the file was downloaded + String filePath = "/home/aissel/Downloads"; + if (isFileDownloaded(filePath)) { + System.out.println("Excel file downloaded successfully."); + } else { + System.out.println("Excel file download failed."); + } + + // Close the WebDriver + driver.quit(); + } + + // Function to check if a file exists + private static boolean isFileDownloaded(String filePath) { + File file = new File(filePath); + return file.exists(); + } + +}*/ + diff --git a/src/test/java/TestScripts/Track_Medinsght_Export.java b/src/test/java/TestScripts/Track_Medinsght_Export.java new file mode 100644 index 0000000..6c2a45f --- /dev/null +++ b/src/test/java/TestScripts/Track_Medinsght_Export.java @@ -0,0 +1,131 @@ +package TestScripts; + +import java.io.File; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +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 com.google.common.collect.ImmutableMap; + +import Utilities.ConfigReader; +import io.github.bonigarcia.wdm.WebDriverManager; + +public class Track_Medinsght_Export +{ + public static void main(String[] args) throws InterruptedException + { + + ChromeOptions options = new ChromeOptions(); + // Set the download directory + options.addArguments("download.default_directory=/home/aissel/git4"); + // Disable the download prompt + options.setExperimentalOption("prefs", + ImmutableMap.of("download.prompt_for_download", false, "download.directory_upgrade", true)); + 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", "set7"}; + //String[] sets = {"set"}; + Thread.sleep(10000); + for (String set : sets) { + Thread.sleep(10000); + String url = config.getProperty(set, "url"); + String username = config.getProperty(set, "username"); + String password = config.getProperty(set, "password"); + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + driver.get(url); + driver.findElement(By.xpath("//input[@id='username']")).sendKeys(username); + driver.findElement(By.xpath("//input[@id='password']")).sendKeys(password); + driver.findElement(By.xpath("//input[@id='kc-login']")).click(); + System.out.println("URL: " + url); + System.out.println("Username: " + username); + + try { + WebElement element = driver.findElement(By.xpath("//div[@class='navLinkTrack sprite_iconSet ']")); + 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(); + Thread.sleep(3000); + + WebElement downloadButton = driver.findElement(By.xpath("//div[@class='excelExportIcon sprite_iconSet tooltip-demo tooltop-left']")); + downloadButton.click(); + Thread.sleep(6000); + // Wait for the download to complete (adjust the timeout as needed) + 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"); + if (downloadedFile.exists()) { + System.out.println("Downloaded file exists."); + } else { + System.out.println("Downloaded file does not exist."); + } + + } 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(); + } + +} + + +/* WebDriverManager.chromedriver().setup(); + WebDriver driver = new ChromeDriver(); + + readConfigFile Config= new readConfigFile(); + + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + driver.get(Config.getURL()); + driver.findElement(By.xpath("//input[@id='username']")).sendKeys(Config.getUSERNAME()); + driver.findElement(By.xpath("//input[@id='password']")).sendKeys(Config.getPASSWORD()); + driver.findElement(By.xpath("//input[@id='kc-login']")).click(); + driver.findElement(By.xpath("//div[@class='navLinkTrack sprite_iconSet ']")).click(); + driver.findElement(By.xpath("//span[normalize-space()='Medical Insight']")).click(); + driver.findElement(By.xpath("//div[@id='resetBttn']")).click(); + + WebElement downloadButton = driver.findElement(By.xpath("//a[@data-original-title='Export Medical Insight Detail into Excel format']")); + downloadButton.click(); + Thread.sleep(6000); + + // Wait for the download to complete (adjust the timeout as needed) + WebDriverWait wait = new WebDriverWait(driver, 30); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@data-original-title='Export Medical Insight Detail into Excel format']"))); + + // Verify the file was downloaded + String filePath = "/home/aissel/Downloads"; + if (isFileDownloaded(filePath)) { + System.out.println("Excel file downloaded successfully."); + } else { + System.out.println("Excel file download failed."); + } + + // Close the WebDriver + driver.quit(); + } + + // Function to check if a file exists + private static boolean isFileDownloaded(String filePath) { + File file = new File(filePath); + return file.exists(); + } +}*/ + diff --git a/src/test/java/TestScripts/Track_Medinsight_Count.java b/src/test/java/TestScripts/Track_Medinsight_Count.java new file mode 100644 index 0000000..518e917 --- /dev/null +++ b/src/test/java/TestScripts/Track_Medinsight_Count.java @@ -0,0 +1,103 @@ +package TestScripts; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebDriver; +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 Utilities.ConfigReader; +import Utilities.readConfigFile; +import io.github.bonigarcia.wdm.WebDriverManager; + +public class Track_Medinsight_Count +{ + 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 = {"set"}; + Thread.sleep(10000); + for (String set : sets) { + Thread.sleep(10000); + String url = config.getProperty(set, "url"); + String username = config.getProperty(set, "username"); + String password = config.getProperty(set, "password"); + driver.manage().window().maximize(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + driver.get(url); + driver.findElement(By.xpath("//input[@id='username']")).sendKeys(username); + driver.findElement(By.xpath("//input[@id='password']")).sendKeys(password); + driver.findElement(By.xpath("//input[@id='kc-login']")).click(); + System.out.println("URL: " + url); + System.out.println("Username: " + username); + try { + WebElement element = driver.findElement(By.xpath("//div[@class='navLinkTrack sprite_iconSet ']")); + 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(); + Thread.sleep(3000); + WebDriverWait wait = new WebDriverWait(driver, 10); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='wrapper']"))); + + + try { + int totalRowCount = 0; + boolean hasNextPage = true; + + while (hasNextPage) { + // Find and count the rows on the current page + List rows = driver.findElements(By.xpath("//table[@aria-labelledby='gbox_listCoachingsResultSet']/tbody/tr")); // Adjust the XPath to match your table structure + int Count = rows.size()-1; + Thread.sleep(3000); + // Exclude the header row if needed + if (Count > 0) { + totalRowCount += Count ; + System.out.println("Total Number of Insight : " + Count); + } + + // Check if there is a next page + WebElement nextPageButton = driver.findElement(By.xpath("//td[@id='next_listCoachingsPage']")); // Adjust the XPath to match your pagination control + if (nextPageButton.getAttribute("class").contains("disabled")) { + hasNextPage = false; + } else { + // Click the "Next" button to navigate to the next page + nextPageButton.click(); + Thread.sleep(5000); + } + } + + System.out.println("Total MedInsight count: " + totalRowCount); + } catch (Exception e) { + e.printStackTrace(); + } finally { + } + } 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(); + } +} + + + + + + diff --git a/src/test/java/Utilities/ConfigReader.java b/src/test/java/Utilities/ConfigReader.java new file mode 100644 index 0000000..dc4eb3c --- /dev/null +++ b/src/test/java/Utilities/ConfigReader.java @@ -0,0 +1,29 @@ +package Utilities; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; +public class ConfigReader +{ + 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 String getProperty(String setName, String key) { + // Combine the set name and key to get the property + return properties.getProperty(setName + "." + key); + } +} + + + + + diff --git a/src/test/java/Utilities/readConfigFile.java b/src/test/java/Utilities/readConfigFile.java new file mode 100644 index 0000000..d2036ea --- /dev/null +++ b/src/test/java/Utilities/readConfigFile.java @@ -0,0 +1,69 @@ +package Utilities; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Properties; + +public class readConfigFile { + + Properties properties; + + String path="/home/aissel/Git2/DICM_Count/src/test/resources/browser-config.properties"; + + public readConfigFile() + { + properties = new Properties(); + + try { + FileInputStream fis = new FileInputStream(path); + try { + properties.load(fis); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + public String getURL() + { + String url=properties.getProperty("url"); + if(url!=null) + return url; + else + throw new RuntimeException("url not specifaid in config file"); + } + + public String getBROWSER() + { + String browser=properties.getProperty("browser"); + if(browser!=null) + return browser; + else + throw new RuntimeException("browser not specifaid in config file"); + } + + public String getUSERNAME() + { + String username=properties.getProperty("username"); + if(username!=null) + return username; + else + throw new RuntimeException("username not specifaid in config file"); + } + + public String getPASSWORD() + { + String password=properties.getProperty("password"); + if(password!=null) + return password; + else + throw new RuntimeException("password not specifaid in config file"); + } + } + + + diff --git a/src/test/resources/browser-config.properties b/src/test/resources/browser-config.properties new file mode 100644 index 0000000..c14af06 --- /dev/null +++ b/src/test/resources/browser-config.properties @@ -0,0 +1,35 @@ + +# Set 1 +set1.url=https://Syros.konectar.io +set1.username=syrosmanager@aissel.com +set1.password=Julkonec*23 + +# Set 2 +set2.url=https://cmsu.konectar.io +set2.username=cmsumanager@aissel.com +set2.password=Jukonec*23 + +# Set 3 +set3.url=https://cardio.konectar.io +set3.username=iteosmgr@aissel.com +set3.password=Jukonec*23 + +# Set 4 +set4.url=https://cardio.konectar.io +set4.username=sareptamgr@aissel.com +set4.password=Jukonec*23 + +# Set 5 +set5.url=https://cardio.konectar.io +set5.username=tika_manager@aissel.com +set5.password=Jukonec*23 + +# Set 6 +set6.url=https://cardio.konectar.io +set6.username=bdtxmanager@aissel.com +set6.password=Welcome@1234 + +# Set 7 +set7.url=https://tidesmedical.konectar.io +set7.username=tidesmanager@aissel.com +set7.password=Jukonec*23 \ No newline at end of file diff --git a/testng.xml b/testng.xml new file mode 100644 index 0000000..7e8317c --- /dev/null +++ b/testng.xml @@ -0,0 +1,9 @@ + + + + + + + + +