Skip to content

Commit

Permalink
Updated to support Katalon Studio 7.x.
Browse files Browse the repository at this point in the history
- Fixed issue with Mobile.delay signature changing from Object to Number
- Updated deprecated Android key press code
  • Loading branch information
ctrevarthen committed Nov 12, 2019
1 parent 290b0e1 commit b7c19c8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ For detailed usage, view the [Javadocs](https://detroit-labs.github.io/katalon-m

To use this **katalon-mobile-util** library in Katalon Studio tests, it is not required that you build from source.

Place the [release artifact jar](https://github.com/detroit-labs/katalon-mobile-util/releases/download/1.13.1/katalon-mobile-util-1.13.1.jar) into your Katalon test project's `/Drivers` directory, or follow the Katalon Studio instructions: [How to import external library into your automation project](https://www.katalon.com/resources-center/tutorials/import-java-library/).
Place the [release artifact jar](https://github.com/detroit-labs/katalon-mobile-util/releases/download/1.14.0/katalon-mobile-util-1.14.0.jar) into your Katalon test project's `/Drivers` directory, or follow the Katalon Studio instructions: [How to import external library into your automation project](https://www.katalon.com/resources-center/tutorials/import-java-library/).

After installation, make sure you restart Katalon Studio for the library to be loaded correctly.

Expand All @@ -61,7 +61,7 @@ Although not required, you may build the **katalon-mobile-util** library from so

### Prerequisites

This library requires [Katalon Studio version 6.2.0](https://www.katalon.com/) to be installed.
This library requires [Katalon Studio version 7.x](https://www.katalon.com/) to be installed.

Building from source requires [Apache Maven](https://maven.apache.org/).

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.detroitlabs</groupId>
<artifactId>katalon-mobile-util</artifactId>
<version>1.13.1</version>
<version>1.14.0</version>
<packaging>jar</packaging>

<name>katalon-mobile-util</name>
Expand All @@ -16,7 +16,7 @@
<!-- Change this to point to your project's /Drivers directory -->
<project.target.katalon.directory>/My-Project/Drivers</project.target.katalon.directory>
<!-- Change this to your Katalon Studio plugins version -->
<project.target.katalon.version>1.0.0.201906110939</project.target.katalon.version>
<project.target.katalon.version>1.0.0.201911010937</project.target.katalon.version>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Run this script from the base katalon-mobile-util directory.
mkdir lib

version="1.0.0.201906110939"
version="1.0.0.201911010937"

mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file \
-Dfile="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/com.kms.katalon.core_${version}.jar" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import org.openqa.selenium.NoSuchElementException;

import java.util.Arrays;
Expand Down Expand Up @@ -80,7 +81,7 @@ public void selectOptionFromPicker(int pickerIndex, String pickerChoice, int tim
p.setValue(pickerChoice);

// In order for the picker change to take effect, need to apply it to the field
driver.pressKeyCode(AndroidKeyCode.ENTER);
driver.pressKey(new KeyEvent(AndroidKey.ENTER));
} catch (NoSuchElementException e) {
selectOptionFromTextList(pickerChoice, timeout);
}
Expand Down Expand Up @@ -110,7 +111,7 @@ public String getPickerValue(Integer timeout) {
public void nextField() {
// For Android, we can use the Tab key
AndroidDriver<?> driver = (AndroidDriver<?>) MobileDriverFactory.getDriver();
driver.pressKeyCode(AndroidKeyCode.KEYCODE_TAB);
driver.pressKey(new KeyEvent(AndroidKey.TAB));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Arrays;
import java.util.List;

import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.interactions.Keyboard;

Expand All @@ -22,7 +24,6 @@
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;

public class TextField {

Expand Down Expand Up @@ -212,7 +213,7 @@ public static void nextField() {
} else {
// For Android, we can use the Tab key
AndroidDriver<?> driver = (AndroidDriver<?>) MobileDriverFactory.getDriver();
driver.pressKeyCode(AndroidKeyCode.KEYCODE_TAB);
driver.pressKey(new KeyEvent(AndroidKey.TAB));
}
}

Expand Down Expand Up @@ -279,7 +280,7 @@ private static void selectOptionFromAndroidPicker(int pickerIndex, String picker
p.setValue(pickerChoice);

// In order for the picker change to take effect, need to apply it to the field
driver.pressKeyCode(AndroidKeyCode.ENTER);
driver.pressKey(new KeyEvent(AndroidKey.ENTER));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void initialize(ScrollFactor scrollFactor) {
* @param timeout delay in seconds between each scroll action.
* @return true if the text was found.
*/
public static boolean scrollListToElementWithText(String elementText, Integer timeout) {
public static boolean scrollListToElementWithText(String elementText, Number timeout) {
return scrollListToElementWithText(elementText, baseScrollFactor, timeout);
}

Expand All @@ -81,7 +81,7 @@ public static boolean scrollListToElementWithText(String elementText, Integer ti
* @param timeout delay in seconds between each scroll action.
* @return true if the text was found.
*/
public static boolean scrollListToElementWithText(String elementText, ScrollFactor scrollFactor, Integer timeout) {
public static boolean scrollListToElementWithText(String elementText, ScrollFactor scrollFactor, Number timeout) {
if (Device.isIOS() || Device.isAndroid()) {
return scrollListToElementWithText(null, elementText, scrollFactor, timeout);
}
Expand All @@ -98,7 +98,7 @@ public static boolean scrollListToElementWithText(String elementText, ScrollFact
* @param timeout delay in seconds between each scroll action.
* @return true if the text was found.
*/
public static boolean scrollListToElementWithText(String elementId, String elementText, Integer timeout) {
public static boolean scrollListToElementWithText(String elementId, String elementText, Number timeout) {
return scrollListToElementWithText(elementId, elementText, baseScrollFactor, timeout);
}

Expand All @@ -111,7 +111,7 @@ public static boolean scrollListToElementWithText(String elementId, String eleme
* @param timeout delay in seconds between each scroll action.
* @return true if the text was found.
*/
public static boolean scrollListToElementWithText(String elementId, String elementText, ScrollFactor scrollFactor, Integer timeout) {
public static boolean scrollListToElementWithText(String elementId, String elementText, ScrollFactor scrollFactor, Number timeout) {
String xpath = "";

if (Device.isIOS()) {
Expand Down Expand Up @@ -142,7 +142,7 @@ public static boolean scrollListToElementWithText(String elementId, String eleme
* @param timeout delay in seconds between each scroll action.
* @return true if the text was found.
*/
public static boolean scrollListToCheckboxWithText(String elementText, Integer timeout) {
public static boolean scrollListToCheckboxWithText(String elementText, Number timeout) {
return scrollListToCheckboxWithText(elementText, baseScrollFactor, timeout);
}

Expand All @@ -157,7 +157,7 @@ public static boolean scrollListToCheckboxWithText(String elementText, Integer t
* @param timeout delay in seconds between each scroll action.
* @return true if the text was found.
*/
public static boolean scrollListToCheckboxWithText(String elementText, ScrollFactor scrollFactor, Integer timeout) {
public static boolean scrollListToCheckboxWithText(String elementText, ScrollFactor scrollFactor, Number timeout) {
String xpath = "";

if (Device.isIOS()) {
Expand All @@ -174,7 +174,7 @@ public static boolean scrollListToCheckboxWithText(String elementText, ScrollFac
return scrollListToElementWithXPath(xpath, elementText, scrollFactor, timeout);
}

private static boolean scrollListToElementWithXPath(String xpath, String elementText, ScrollFactor scrollFactor, Integer timeout) {
private static boolean scrollListToElementWithXPath(String xpath, String elementText, ScrollFactor scrollFactor, Number timeout) {
boolean isElementFound = false;
while (isElementFound == false) {
try {
Expand All @@ -196,7 +196,7 @@ private static boolean scrollListToElementWithXPath(String xpath, String element
return isElementFound;
}

private static void scrollEntireList(String xpath, String elementText, ScrollFactor scrollFactor, Integer timeout) {
private static void scrollEntireList(String xpath, String elementText, ScrollFactor scrollFactor, Number timeout) {
AppiumDriver<?> driver = MobileDriverFactory.getDriver();

Logger.debug("Getting a scroll list of all elements.");
Expand Down

0 comments on commit b7c19c8

Please sign in to comment.