-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 88e27da
Showing
60 changed files
with
1,949 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/bin/ | ||
/Libs/ | ||
/.settings/ | ||
/.classpath | ||
.svn/ | ||
/Reports | ||
/.project | ||
/.gradle/ | ||
/Drivers/ | ||
settings/internal/com.kms.katalon.integration.analytics.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<GlobalVariableEntities> | ||
<description></description> | ||
<tag></tag> | ||
<GlobalVariableEntity> | ||
<description></description> | ||
<initValue>10</initValue> | ||
<name>G_Timeout</name> | ||
</GlobalVariableEntity> | ||
<GlobalVariableEntity> | ||
<description></description> | ||
<initValue>'http://demoaut.katalon.com'</initValue> | ||
<name>G_SiteURL</name> | ||
</GlobalVariableEntity> | ||
<GlobalVariableEntity> | ||
<description></description> | ||
<initValue>5</initValue> | ||
<name>G_ShortTimeOut</name> | ||
</GlobalVariableEntity> | ||
</GlobalVariableEntities> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# This file is used to configure Katalon Studio execution log levels. | ||
|
||
# When you need to troubleshoot Katalon Studio issue | ||
# logging.level.com.kms=TRACE | ||
|
||
# logging.level.com.mycompany=DEBUG |
181 changes: 181 additions & 0 deletions
181
Include/scripts/groovy/com/katalon/KatalonHelper.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
package com.katalon | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
import org.apache.commons.lang.StringEscapeUtils | ||
import org.apache.commons.lang.StringUtils | ||
|
||
import com.kms.katalon.core.configuration.RunConfiguration | ||
import com.kms.katalon.core.testobject.ConditionType | ||
import com.kms.katalon.core.testobject.RestRequestObjectBuilder | ||
import com.kms.katalon.core.testobject.TestObjectProperty | ||
import com.kms.katalon.core.testobject.UrlEncodedBodyParameter | ||
import com.kms.katalon.core.webservice.common.ServiceRequestFactory | ||
import com.kms.katalon.util.CryptoUtil | ||
import com.kms.katalon.core.util.internal.JsonUtil; | ||
|
||
import groovy.json.JsonSlurper | ||
|
||
trait IgnoreUnknownProperties { | ||
def propertyMissing(name, value){ | ||
// do nothing | ||
} | ||
} | ||
|
||
class Project implements IgnoreUnknownProperties { | ||
Long id; | ||
String name; | ||
Long teamId; | ||
} | ||
|
||
class Team implements IgnoreUnknownProperties { | ||
Long id; | ||
String role; | ||
String name; | ||
Organization organization; | ||
} | ||
|
||
class Organization implements IgnoreUnknownProperties { | ||
Long id; | ||
String role; | ||
String name; | ||
} | ||
|
||
|
||
public class KatalonHelper { | ||
|
||
private static final String DEFAULT_SERVER_URL = "https://analytics.katalon.com" | ||
private static final String HEADER_VALUE_AUTHORIZATION_PREFIX = "Bearer "; | ||
private static final String HEADER_AUTHORIZATION = "Authorization"; | ||
private static final String HEADER_AUTHORIZATION_PREFIX = "Basic "; | ||
private static final String OAUTH2_CLIENT_ID = "kit_uploader"; | ||
private static final String OAUTH2_CLIENT_SECRET = "kit_uploader"; | ||
|
||
|
||
private static final String LOGIN_PARAM_PASSWORD = "password"; | ||
private static final String LOGIN_PARAM_USERNAME = "username"; | ||
private static final String LOGIN_PARAM_GRANT_TYPE_NAME = "grant_type"; | ||
private static final String LOGIN_PARAM_GRANT_TYPE_VALUE = "password"; | ||
|
||
|
||
public static final String KATALON_HOME_ENV_NAME = "KATALON_HOME" | ||
public static final String KATALON_HOME_DIR = System.getenv(KATALON_HOME_ENV_NAME) != null ? System.getenv(KATALON_HOME_ENV_NAME) : System.getProperty("user.home"); | ||
public static final String APP_USER_DIR_LOCATION = KATALON_HOME_DIR + File.separator + ".katalon"; | ||
|
||
public static void updateInfo() { | ||
try{ | ||
Path testOpsSettingsPath = Paths.get(RunConfiguration.getProjectDir(), | ||
'settings', 'internal', 'com.kms.katalon.integration.analytics.properties') | ||
File testOpsSettingsFile = testOpsSettingsPath.toFile() | ||
if(!isIntegratedEnabled(testOpsSettingsFile)){ | ||
Properties userProperties = getUserProperties() | ||
String username = userProperties.getProperty('email') | ||
String encryptedPassword = userProperties.getProperty('password') | ||
String password = (CryptoUtil.decode(CryptoUtil.getDefault(encryptedPassword))) | ||
String serverUrl = userProperties.getProperty('testOps.serverUrl') | ||
if(StringUtils.isBlank(serverUrl)){ | ||
serverUrl = DEFAULT_SERVER_URL | ||
} | ||
String token = requestToken(serverUrl, username, password) | ||
def (project, team) = getFirstProject(serverUrl, token) | ||
if(project != null && team != null){ | ||
Properties properties = new Properties() | ||
properties.setProperty('analytics.authentication.token', getRawValue(token)) | ||
properties.setProperty('analytics.integration.enable', 'true') | ||
properties.setProperty('analytics.team', getRawValue(JsonUtil.toJson(team))) | ||
properties.setProperty('analytics.project', getRawValue(JsonUtil.toJson(project))) | ||
properties.setProperty('analytics.testresult.autosubmit', 'true') | ||
|
||
FileOutputStream fos = new FileOutputStream(testOpsSettingsFile) | ||
properties.store(fos, null) | ||
} | ||
} | ||
} catch (Exception e){ | ||
// do nothing | ||
} | ||
} | ||
|
||
public static String getRawValue(String value) { | ||
if (value == null) | ||
return null; | ||
else { | ||
return "\"" + StringEscapeUtils.escapeJava((String) value) + "\""; | ||
} | ||
} | ||
|
||
private static String requestToken(serverUrl, username, password) { | ||
String clientCredentials = OAUTH2_CLIENT_ID + ":" + OAUTH2_CLIENT_SECRET; | ||
String url = serverUrl + "/oauth/token" | ||
def builder = new RestRequestObjectBuilder() | ||
def request = builder | ||
.withRestRequestMethod("POST") | ||
.withRestUrl(url) | ||
.withHttpHeaders([ | ||
new TestObjectProperty("Content-Type", ConditionType.EQUALS, "application/x-www-form-urlencoded"), | ||
new TestObjectProperty(HEADER_AUTHORIZATION, ConditionType.EQUALS, | ||
HEADER_AUTHORIZATION_PREFIX + Base64.getEncoder().encodeToString(clientCredentials.getBytes())) | ||
]) | ||
.withUrlEncodedBodyContent([ | ||
new UrlEncodedBodyParameter(LOGIN_PARAM_USERNAME, username), | ||
new UrlEncodedBodyParameter(LOGIN_PARAM_PASSWORD, password), | ||
new UrlEncodedBodyParameter(LOGIN_PARAM_GRANT_TYPE_NAME, LOGIN_PARAM_GRANT_TYPE_VALUE), | ||
]) | ||
.build() | ||
def response = ServiceRequestFactory.getInstance(request).send(request) | ||
|
||
def responseBody = response.getResponseText() | ||
def jsonSlurper = new JsonSlurper() | ||
def object = jsonSlurper.parseText(responseBody) | ||
|
||
return object.access_token | ||
} | ||
|
||
private static def getFirstProject(serverUrl, token) { | ||
String url = serverUrl + "/api/v1/projects/first" | ||
def builder = new RestRequestObjectBuilder() | ||
def request = builder | ||
.withRestRequestMethod("GET") | ||
.withRestUrl(url) | ||
.withHttpHeaders([ | ||
new TestObjectProperty(HEADER_AUTHORIZATION, ConditionType.EQUALS, | ||
HEADER_VALUE_AUTHORIZATION_PREFIX + token) | ||
]) | ||
.build() | ||
def response = ServiceRequestFactory.getInstance(request).send(request) | ||
|
||
def responseBody = response.getResponseText() | ||
def jsonSlurper = new JsonSlurper() | ||
def projects = jsonSlurper.parseText(responseBody) | ||
if(projects.size() > 0){ | ||
def firstProject = projects.get(0) | ||
return [ | ||
new Project(firstProject), | ||
new Team(firstProject.team) | ||
] | ||
} else { | ||
return [null, null] | ||
} | ||
} | ||
|
||
private static Properties getUserProperties() { | ||
Path path = Paths.get(APP_USER_DIR_LOCATION, 'application.properties') | ||
File file = path.toFile(); | ||
InputStream inputStream = new FileInputStream(file) | ||
Properties properties = new Properties() | ||
properties.load(inputStream) | ||
return properties | ||
} | ||
|
||
private static boolean isIntegratedEnabled(File settingsFile) { | ||
if(!settingsFile.exists()){ | ||
return false | ||
} | ||
settingsFile.withInputStream{ stream -> | ||
Properties properties = new Properties() | ||
properties.load(stream) | ||
String project = properties.getProperty('analytics.project') | ||
return project != null | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.example | ||
import groovy.json.JsonSlurper | ||
|
||
import org.jsoup.Jsoup | ||
import org.jsoup.nodes.Document | ||
import org.jsoup.nodes.Element | ||
import org.jsoup.select.Elements | ||
import org.openqa.selenium.By | ||
import org.openqa.selenium.WebElement | ||
|
||
import com.kms.katalon.core.annotation.Keyword | ||
import com.kms.katalon.core.model.FailureHandling | ||
import com.kms.katalon.core.testobject.TestObject | ||
import com.kms.katalon.core.testobject.TestObjectProperty | ||
import com.kms.katalon.core.testobject.ResponseObject | ||
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords | ||
|
||
|
||
public class WebUICustomKeywords { | ||
|
||
/** | ||
* Check if element present in timeout | ||
* @param to Katalon test object | ||
* @param timeout time to wait for element to show up | ||
* @return true if element present, otherwise false | ||
*/ | ||
@Keyword | ||
def isElementPresent(TestObject to, int timeout){ | ||
//Use Katalon built-in function to find elements with time out 1 seconds | ||
List<WebElement> elements = WebUiBuiltInKeywords.findWebElements(to, timeout) | ||
return elements.size() > 0 | ||
} | ||
|
||
/** | ||
* Get all rows of HTML table | ||
* @param table Katalon test object represent for HTML table | ||
* @param outerTagName outer tag name of TR tag, usually is TBODY | ||
* @return All rows inside HTML table | ||
*/ | ||
@Keyword | ||
def List<WebElement> getHtmlTableRows(TestObject table, String outerTagName) { | ||
WebElement mailList = WebUiBuiltInKeywords.findWebElement(table) | ||
List<WebElement> selectedRows = mailList.findElements(By.xpath("./" + outerTagName + "/tr")) | ||
return selectedRows | ||
} | ||
|
||
/** | ||
* Get all cells of HTML table row | ||
* @param row a WebElement instance represent for HTML table row | ||
* @param tagName HTML column tag name, usually is TD/TH | ||
* @return All cells inside HTML table row | ||
*/ | ||
@Keyword | ||
def List<WebElement> getHtmlTableColumns(WebElement row, String tagName) { | ||
List<WebElement> selectedColumns = row.findElements(By.tagName(tagName)) | ||
return selectedColumns | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Object Repository/Page_AppointmentConfirmation/lbl_Comment.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<WebElementEntity> | ||
<description></description> | ||
<name>lbl_Comment</name> | ||
<tag></tag> | ||
<elementGuidId>b70ba152-d5df-4e11-9c8a-4730577f03f8</elementGuidId> | ||
<useRalativeImagePath>false</useRalativeImagePath> | ||
<webElementProperties> | ||
<isSelected>true</isSelected> | ||
<matchCondition>equals</matchCondition> | ||
<name>id</name> | ||
<type>Main</type> | ||
<value>comment</value> | ||
</webElementProperties> | ||
</WebElementEntity> |
15 changes: 15 additions & 0 deletions
15
Object Repository/Page_AppointmentConfirmation/lbl_Facility.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<WebElementEntity> | ||
<description></description> | ||
<name>lbl_Facility</name> | ||
<tag></tag> | ||
<elementGuidId>92d3b773-3c29-45a7-b748-664c54dbe332</elementGuidId> | ||
<useRalativeImagePath>false</useRalativeImagePath> | ||
<webElementProperties> | ||
<isSelected>true</isSelected> | ||
<matchCondition>equals</matchCondition> | ||
<name>id</name> | ||
<type>Main</type> | ||
<value>facility</value> | ||
</webElementProperties> | ||
</WebElementEntity> |
15 changes: 15 additions & 0 deletions
15
Object Repository/Page_AppointmentConfirmation/lbl_HospitalReadmission.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<WebElementEntity> | ||
<description></description> | ||
<name>lbl_HospitalReadmission</name> | ||
<tag></tag> | ||
<elementGuidId>2b1c78d6-27b9-4a6f-8202-a078a5906760</elementGuidId> | ||
<useRalativeImagePath>false</useRalativeImagePath> | ||
<webElementProperties> | ||
<isSelected>true</isSelected> | ||
<matchCondition>equals</matchCondition> | ||
<name>id</name> | ||
<type>Main</type> | ||
<value>hospital_readmission</value> | ||
</webElementProperties> | ||
</WebElementEntity> |
15 changes: 15 additions & 0 deletions
15
Object Repository/Page_AppointmentConfirmation/lbl_Program.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<WebElementEntity> | ||
<description></description> | ||
<name>lbl_Program</name> | ||
<tag></tag> | ||
<elementGuidId>ed12c1cf-7f76-4e6c-959a-7453fd4a3c45</elementGuidId> | ||
<useRalativeImagePath>false</useRalativeImagePath> | ||
<webElementProperties> | ||
<isSelected>true</isSelected> | ||
<matchCondition>equals</matchCondition> | ||
<name>id</name> | ||
<type>Main</type> | ||
<value>program</value> | ||
</webElementProperties> | ||
</WebElementEntity> |
15 changes: 15 additions & 0 deletions
15
Object Repository/Page_AppointmentConfirmation/lbl_VisitDate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<WebElementEntity> | ||
<description></description> | ||
<name>lbl_VisitDate</name> | ||
<tag></tag> | ||
<elementGuidId>46fc49f1-29f3-4124-9275-0563c48d8381</elementGuidId> | ||
<useRalativeImagePath>false</useRalativeImagePath> | ||
<webElementProperties> | ||
<isSelected>true</isSelected> | ||
<matchCondition>equals</matchCondition> | ||
<name>id</name> | ||
<type>Main</type> | ||
<value>visit_date</value> | ||
</webElementProperties> | ||
</WebElementEntity> |
15 changes: 15 additions & 0 deletions
15
Object Repository/Page_CuraAppointment/btn_BookAppointment.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<WebElementEntity> | ||
<description></description> | ||
<name>btn_BookAppointment</name> | ||
<tag></tag> | ||
<elementGuidId>61c6be2b-37a2-4d86-980b-785e985fb89d</elementGuidId> | ||
<useRalativeImagePath>false</useRalativeImagePath> | ||
<webElementProperties> | ||
<isSelected>true</isSelected> | ||
<matchCondition>equals</matchCondition> | ||
<name>id</name> | ||
<type>Main</type> | ||
<value>btn-book-appointment</value> | ||
</webElementProperties> | ||
</WebElementEntity> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<WebElementEntity> | ||
<description></description> | ||
<name>chk_Medicaid</name> | ||
<tag></tag> | ||
<elementGuidId>a9ef1a35-94ae-4c4e-bc9f-a4290a17ff33</elementGuidId> | ||
<useRalativeImagePath>false</useRalativeImagePath> | ||
<webElementProperties> | ||
<isSelected>true</isSelected> | ||
<matchCondition>equals</matchCondition> | ||
<name>id</name> | ||
<type>Main</type> | ||
<value>radio_program_medicaid</value> | ||
</webElementProperties> | ||
</WebElementEntity> |
Oops, something went wrong.