Skip to content

Katalon updates #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 3 additions & 31 deletions Controlium.iml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="ExternalSystem" externalSystem="Maven" />
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_9">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/Test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
Expand Down Expand Up @@ -39,40 +37,14 @@
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.6" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.9.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
<orderEntry type="library" name="Maven: org.teamcontrolium:utilities:1.1.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-java:3.11.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-api:3.11.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-chrome-driver:3.11.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-edge-driver:3.11.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-firefox-driver:3.11.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-ie-driver:3.11.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-opera-driver:3.11.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-remote-driver:3.11.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-safari-driver:3.11.0" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-support:3.11.0" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.7.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-exec:1.3" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.2" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:23.6-jre" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" name="Maven: org.checkerframework:checker-compat-qual:2.0.0" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.1.3" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.6" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.9.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" />
<orderEntry type="library" name="Maven: org.mod4j.org.apache.commons:lang:2.1.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: org.jsoup:jsoup:1.11.2" level="project" />
<orderEntry type="library" name="Maven: org.teamcontrolium:utilities:1.2.3" level="project" />
<orderEntry type="library" name="Maven: org.junit.jupiter:junit-jupiter-api:5.0.0" level="project" />
<orderEntry type="library" name="Maven: org.apiguardian:apiguardian-api:1.0.0" level="project" />
<orderEntry type="library" name="Maven: org.opentest4j:opentest4j:1.0.0" level="project" />
<orderEntry type="library" name="Maven: org.junit.platform:junit-platform-commons:1.0.0" level="project" />
<orderEntry type="library" name="Maven: org.jsoup:jsoup:1.11.2" level="project" />
<orderEntry type="library" name="Maven: org.teamcontrolium:utilities:1.1.0" level="project" />
</component>
</module>
81 changes: 70 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>TeamControlium Controlium control-based Selenium abstraction</name>
<groupId>org.testcontrolium</groupId>
<groupId>org.teamcontrolium</groupId>
<artifactId>controlium</artifactId>
<version>1.0</version>
<version>1.1.0</version>
<description>TeamControlium Controlium provides the API and foundations for Control-based use of Selenium</description>
<url>https://github.com/TeamControlium</url>
<inceptionYear>2017</inceptionYear>
Expand All @@ -17,7 +17,7 @@
<licenses>
<license>
<name>The MIT License</name>
<url>https://github.com/TeamControlium/Controlium.java/blob/master/LICENSE</url>
<url>https://github.com/TeamControlium/Controlium.java/blob/master/LICENSE.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
Expand All @@ -39,10 +39,64 @@
<version>3.7.0</version>
<configuration>
<!-- or whatever version you use -->
<source>10</source>
<target>10</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -70,11 +124,6 @@
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<!-- jsoup HTML parser library @ https://jsoup.org/ -->
<groupId>org.jsoup</groupId>
Expand All @@ -84,7 +133,7 @@
<dependency>
<groupId>org.teamcontrolium</groupId>
<artifactId>utilities</artifactId>
<version>1.1.0</version>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -107,6 +156,16 @@
</roles>
<timezone>+10</timezone>
</developer>
<developer>
<id>K8Coder</id>
<name>Kate More</name>
<email>[email protected]</email>
<roles>
<role>Java Developer</role>
</roles>
<organization>TeamControlium Committers</organization>
<timezone>+10</timezone>
</developer>
</developers>

</project>
51 changes: 48 additions & 3 deletions src/main/java/TeamControlium/Controlium/ControlBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ public static <T extends ControlBase> T setControl(SeleniumDriver seleniumDriver
StopWatch timeWaited = StopWatch.createStarted();

try {
Logger.WriteLine(Logger.LogLevels.TestInformation, "Setting on Control [%s] from Parent [%s]",
Logger.WriteLine(Logger.LogLevels.TestInformation, "Setting on Control [%s] from Parent [%s] with SeleniumDriver hash [%s] (WebDriver hash [%s])",
newControl.getMapping() == null ? "No mapping logic!" : newControl.getMapping().getFriendlyName(),
parentControl == null ? "No parent Control - So Top Level control" : parentControl.getMapping() == null ? "No mapping logic!" : parentControl.getMapping().getFriendlyName());

parentControl == null ? "No parent Control - So Top Level control" : parentControl.getMapping() == null ? "No mapping logic!" : parentControl.getMapping().getFriendlyName(),
seleniumDriver==null?"null":Integer.toString(seleniumDriver.hashCode()),
seleniumDriver==null?"N/A":(seleniumDriver.getWebDriver()==null?"Null!":Integer.toString(seleniumDriver.getWebDriver().hashCode())));
//
// Check if ParentControl has become stale (has been redrawn). If so, refresh it (force a new findElement on it). Note that this
// will effectively ripple up to the top level
Expand Down Expand Up @@ -149,6 +150,11 @@ public static <T extends ControlBase> T setControl(SeleniumDriver seleniumDriver
}
}

public static <T extends ControlBase> boolean controlExists(ControlBase parentControl,T control) { return parentControl.elementExists(control.getMapping());}
public static <T extends ControlBase> boolean controlExists(SeleniumDriver seleniumDriver, T control) { return seleniumDriver.findElementOrNull(control.getMapping())!=null;}
public static <T extends ControlBase> boolean controlExists(SeleniumDriver seleniumDriver, ControlBase parentControl, T control) { return seleniumDriver.findElement(parentControl.getMapping()).findElementOrNull(control.getMapping())!=null;}

public <T extends ControlBase> boolean controlExists(T control) {return this.elementExists(control.getMapping());}
//
// All Controls must implement a ControlBeingSet. This is called when the Control is set upon (IE. Find logic applied and bound to a Selenium element). It really
// will become useful when caching is implemented. It is used by a Control to do stuff when located in the Dom - IE. A dropdown control may click on it whenever
Expand All @@ -175,6 +181,9 @@ public boolean isStale() {
}
}

public boolean elementExists(ObjectMapping mapping) {
return getRootElement().findElementOrNull(mapping)!=null;
}

public void clearElement(ObjectMapping mapping) {
findElement(mapping).clear();
Expand Down Expand Up @@ -240,6 +249,42 @@ public boolean hasAttribute(String attributeName) {
}
}

public String getCssValue(ObjectMapping mapping, String valueName) {
HTMLElement element = findElement(mapping);
try {
return element.getCssValue(valueName);
}
catch (Exception e) {
return "";
}
}
public String getCssValue(String valueName) {
try {
return getRootElement().getCssValue(valueName);
}
catch (Exception e) {
return "";
}
}

public boolean hasCssValue(ObjectMapping mapping, String valueName) {
HTMLElement element = findElement(mapping);
try {
return element.hasCssValue(valueName);
}
catch (Exception e) {
return false;
}
}
public boolean hasCssValue(String valueName) {
try {
return getRootElement().hasCssValue(valueName);
}
catch (Exception e) {
return false;
}
}

public String getText(ObjectMapping mapping) {
HTMLElement element = findElement(mapping);
try {
Expand Down
44 changes: 40 additions & 4 deletions src/main/java/TeamControlium/Controlium/HTMLElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public void setText(String text,Duration retryInterval) {
setText(text,1,retryInterval);}
public void setText(String text,int maxTries,Duration retryInterval)
{
RuntimeException lastException=null;
Exception lastException=null;
throwIfUnbound();
if (maxTries<1) throw new RuntimeException(String.format("Maximum tries [%d]. Cannot be less than 1.",maxTries));
int tryIndex = 0;
Expand All @@ -435,6 +435,7 @@ public void setText(String text,int maxTries,Duration retryInterval)
{
try
{
Logger.WriteLine(Logger.LogLevels.FrameworkDebug,"Calling Selenium driver clear with WebElement. Driver %s, Element %s",getSeleniumDriver()==null?"Null":"Good",getUnderlyingWebElement()==null?"Null!":"Good");
getSeleniumDriver().clear(this.getUnderlyingWebElement());
enterText(text);
if (tryIndex > 1) Logger.WriteLine(Logger.LogLevels.FrameworkDebug, "{0} attempt attempt good.)", tryIndex);
Expand All @@ -445,11 +446,16 @@ public void setText(String text,int maxTries,Duration retryInterval)
Thread.sleep(retryInterval.toMillis());
lastException = e;
}
catch (Exception e)
{
Thread.sleep(retryInterval.toMillis());
lastException = e;
}
}
throw lastException;
}
catch (InvalidElementState ex) {
Logger.WriteLine(Logger.LogLevels.Error,"Error thrown setting text (clear then enter) in [%s] (Tried %d times): %s",getFriendlyName(),tryIndex,ex.getMessage());
Logger.WriteLine(Logger.LogLevels.Error,"Error thrown setting text (clear then enter) in [%s] (Tried %d times): %s",getFriendlyName(),tryIndex,ex);
throw new InvalidElementState(String.format("Error thrown setting text (clear then enter) in [%s] ([%s]). Tried %d times).",getFriendlyName(),getMappingDetails().getActualFindLogic(),tryIndex),ex);

}
Expand Down Expand Up @@ -480,6 +486,7 @@ public void enterText(String text,int maxTries,Duration retryInterval) {
{
try
{
Logger.WriteLine(Logger.LogLevels.FrameworkDebug,"Calling Selenium driver setText with WebElement. Driver %s, Element %s, text = [%s]",getSeleniumDriver()==null?"Null":"Good",getUnderlyingWebElement()==null?"Null!":"Good",text==null?"<null!>":text);
getSeleniumDriver().setText(this.getUnderlyingWebElement(),(text==null)?"":text);
if (tryIndex > 1) Logger.WriteLine(Logger.LogLevels.FrameworkDebug, "{0} attempt attempt good.)", tryIndex);
return;
Expand Down Expand Up @@ -549,7 +556,7 @@ public String getAttribute(String attribute) {
throw ex;
}
catch (Exception e) {
Logger.WriteLine(Logger.LogLevels.TestInformation,"Error thrown getting attribute [%s] from [%s]: %s",getFriendlyName(),e.getMessage());
Logger.WriteLine(Logger.LogLevels.TestInformation,"Error thrown getting attribute [%s] from [%s]: %s",attribute,getFriendlyName(),e.getMessage());
throw new RuntimeException(String.format("Error thrown getting attribute [%s] from [%s] ([%s])",attribute==null?"Null":attribute,getFriendlyName(),getMappingDetails().getActualFindLogic()),e);
}
}
Expand All @@ -563,11 +570,40 @@ public boolean hasAttribute(String attribute) {
throw ex;
}
catch (Exception e) {
Logger.WriteLine(Logger.LogLevels.TestDebug,"Error thrown getting attribute [%s] from [%s]. Assume does not have attribute: %s",getFriendlyName(),e.getMessage());
Logger.WriteLine(Logger.LogLevels.TestDebug,"Error thrown getting attribute [%s] from [%s]. Assume does not have attribute: %s",attribute,getFriendlyName(),e.getMessage());
return false;
}
}

public String getCssValue(String valueName) {
throwIfUnbound();
try {
return getSeleniumDriver().getCssValue(getUnderlyingWebElement(),valueName);
}
catch (InvalidElementState ex) {
throw ex;
}
catch (Exception e) {
Logger.WriteLine(Logger.LogLevels.TestInformation,"Error thrown getting CSS value [%s] from [%s]: %s",valueName,getFriendlyName(),e.getMessage());
throw new RuntimeException(String.format("Error thrown getting CSS value [%s] from [%s] ([%s])",valueName==null?"Null":valueName,getFriendlyName(),getMappingDetails().getActualFindLogic()),e);
}
}

public boolean hasCssValue(String valueName) {
throwIfUnbound();
try {
return getSeleniumDriver().hasCssValue(getUnderlyingWebElement(),valueName);
}
catch (InvalidElementState ex) {
throw ex;
}
catch (Exception e) {
Logger.WriteLine(Logger.LogLevels.TestDebug,"Error thrown getting CSS value [%s] from [%s]. Assume does not have CSS value: %s",valueName,getFriendlyName(),e.getMessage());
return false;
}
}


public void click() {
throwIfUnbound();
try {
Expand Down
Loading