Skip to content

Commit

Permalink
rE-
Browse files Browse the repository at this point in the history
MOVE SPRING
  • Loading branch information
TayGov committed Jun 4, 2024
1 parent 4cad8dd commit 3d4abdb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 189 deletions.
17 changes: 1 addition & 16 deletions cccm-automation-test-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@

<name>CCCM-testing</name>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<io.github.bonigarcia.version>5.6.3</io.github.bonigarcia.version>
<org.seleniumhq.selenium.version>4.11.0</org.seleniumhq.selenium.version>
<org.seleniumhq.selenium.version>4.13.0</org.seleniumhq.selenium.version>
<com.microsoft.sqlserver.version>6.4.0.jre8</com.microsoft.sqlserver.version>
<junit.version>4.13.1</junit.version>
<org.apache.pdfbox.version>2.0.26</org.apache.pdfbox.version>
Expand All @@ -29,16 +24,6 @@

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>

<!-- Selenium Drivers -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
package ca.bc.gov.open.jag;

import ca.bc.gov.open.jag.properties.TestProperties;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import java.time.Duration;

@EnableConfigurationProperties
public class CommonMethods {

private static TestProperties testProperties;

public CommonMethods(TestProperties testProperties) {
this.testProperties = testProperties;
}

private static int defaultSleepBeforeAction = 1;
private static String appUSERNAME = System.getenv("USERNAME_APP");
private static String appPASSWORD = System.getenv("PASSWORD_APP");

public static void login() throws Exception {

Expand All @@ -31,9 +25,9 @@ public static void login() throws Exception {
WebDriverWait driverWait = CustomWebDriverManager.getDriverWait();

WebElement element = driverWait.until(ExpectedConditions.presenceOfElementLocated(By.id("username")));
element.sendKeys(testProperties.getUsernameApp());
element.sendKeys(appUSERNAME);
element = driverWait.until(ExpectedConditions.presenceOfElementLocated(By.id("password")));
element.sendKeys(testProperties.getPasswordApp());
element.sendKeys(appPASSWORD);
element = driverWait.until(ExpectedConditions.presenceOfElementLocated(By.name("login")));
element.click();

Expand All @@ -49,7 +43,7 @@ public static void clientSearchByCSNumber(String CSNumber) throws InterruptedExc

System.out.println("Client search with CSNumber: '" + CSNumber + "' is started");

driver.get(String.format("%s/%s", testProperties.getBaseUrl(), "clientsearch"));
driver.get("https://dev.jag.gov.bc.ca/cccm/clientsearch");
new WebDriverWait(driver, Duration.ofSeconds(20)).until(ExpectedConditions.presenceOfElementLocated(
By.xpath("//*[contains(text(), 'Client Search')]")));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
package ca.bc.gov.open.jag;

import ca.bc.gov.open.jag.properties.TestProperties;
import org.openqa.selenium.*;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

@EnableConfigurationProperties
public class CommonUtils {

private static TestProperties testProperties;

public CommonUtils(TestProperties testProperties) {
this.testProperties = testProperties;
}

private static Logger log = Logger.getLogger("CommonUtils.class");

public static void openLogin() throws Exception {
Expand All @@ -27,56 +18,14 @@ public static void openLogin() throws Exception {


driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
driver.get(testProperties.getBaseUrl());
driver.get("https://dev.jag.gov.bc.ca/cccm");

} else if (Config.ENVIROMENT.equals(Constants.TST)) {
driver.get(testProperties.getBaseUrl());
driver.navigate().to(testProperties.getBaseUrl());
driver.get("https://test.jag.gov.bc.ca/cccm");
driver.navigate().to("https://test.jag.gov.bc.ca/cccm");
driver.navigate().refresh();

}
}

// Construct jdbcUrl for Environment
public static String getJdbcUrl() {
String jdbcUrl = "";
if (Config.ENVIROMENT.equals(Constants.DEV)) {
jdbcUrl = testProperties.getDbConnection();
} else if (Config.ENVIROMENT.equals(Constants.TST)) {
jdbcUrl = testProperties.getDbConnection();
}

String dbName = "";

if (Config.ENVIROMENT.equals(Constants.DEV)) {
dbName = "DatabaseName=";
} else if (Config.ENVIROMENT.equals(Constants.TST)) {
dbName = "DatabaseName=";
}

return jdbcUrl;
}

// Construct userName for Environment
public static String getJdbcUserName() {
String userName = "";
if (Config.ENVIROMENT.equals(Constants.DEV)) {
userName = "jdbcUserName.DEV";
} else if (Config.ENVIROMENT.equals(Constants.TST)) {
userName = "jdbcUserName.TST";
}
return userName;
}

// Construct password for Environment
public static String getJdbcPassword() {
String password = "";
if (Config.ENVIROMENT.equals(Constants.DEV)) {
password = "jdbcPassword.DEV";
} else if (Config.ENVIROMENT.equals(Constants.TST)) {
password = "jdbcPassword.TST";
}
return password;
}

}

This file was deleted.

This file was deleted.

0 comments on commit 3d4abdb

Please sign in to comment.