Skip to content

fix: provide mandatory automation name for Android #242

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

Merged
Merged
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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
<a name="6.0.0"></a>
# [6.0.0](https://github.com/NativeScript/nativescript-dev-appium/compare/5.3.0...6.0.0) (2019-08-08)


### Bug Fixes

* typos ([65c6aa3](https://github.com/NativeScript/nativescript-dev-appium/commit/65c6aa3))
* **image-helper:** increase image name ([#237](https://github.com/NativeScript/nativescript-dev-appium/issues/237)) ([c075af8](https://github.com/NativeScript/nativescript-dev-appium/commit/c075af8))


### Features

* image-helper ([#236](https://github.com/NativeScript/nativescript-dev-appium/issues/236)) ([0d2c9fd](https://github.com/NativeScript/nativescript-dev-appium/commit/0d2c9fd))
* resolve symlinked storages ([#235](https://github.com/NativeScript/nativescript-dev-appium/issues/235)) ([ef270c9](https://github.com/NativeScript/nativescript-dev-appium/commit/ef270c9))



<a name="5.3.0"></a>
# [5.3.0](https://github.com/NativeScript/nativescript-dev-appium/compare/v5.2.0...v5.3.0) (2019-06-10)

Expand Down
1 change: 1 addition & 0 deletions lib/automation-name.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export declare enum AutomationName {
UiAutomator2 = "UIAutomator2",
UiAutomator1 = "UIAutomator1",
Appium = "Appium",
XCUITest = "XCUITest"
}
1 change: 1 addition & 0 deletions lib/automation-name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum AutomationName {
UiAutomator2 = "UIAutomator2",
UiAutomator1 = "UIAutomator1",
Appium = "Appium",
XCUITest = "XCUITest",
}
1 change: 1 addition & 0 deletions lib/ns-capabilities.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export declare class NsCapabilities implements INsCapabilities {
shouldSetFullResetOption(): void;
private setAutomationName;
tryGetAndroidApiLevel(): number;
tryGetIOSApiLevel(): number;
private resolveApplication;
private checkMandatoryCapabilities;
private throwExceptions;
Expand Down
26 changes: 21 additions & 5 deletions lib/ns-capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,25 @@ export class NsCapabilities implements INsCapabilities {
this.automationName = AutomationName.Appium; break;
case AutomationName.XCUITest.toString().toLowerCase():
this.automationName = AutomationName.XCUITest; break;
case AutomationName.UiAutomator1.toString().toLowerCase():
this.automationName = AutomationName.UiAutomator1; break;
}
} else {
const apiLevel = this.tryGetApiLevel();
if (this.isAndroid) {
if (this.tryGetAndroidApiLevel() >= 6 || (this.appiumCaps["apiLevel"] && +this.appiumCaps["apiLevel"]) >= 23) {
if ((apiLevel >= 6 && apiLevel <= 17)
|| apiLevel >= 23) {
this.automationName = AutomationName.UiAutomator2;
} else {
this.automationName = AutomationName.UiAutomator1;
}
}

if (this.isIOS) {
if (apiLevel < 10) {
logWarn("Provide automationName")
} else {
this.automationName = AutomationName.XCUITest;
}
}
}
Expand All @@ -327,13 +341,15 @@ export class NsCapabilities implements INsCapabilities {
}
}

tryGetAndroidApiLevel() {
tryGetApiLevel() {
try {
if (this.appiumCaps["platformVersion"]) {
const apiLevel = this.appiumCaps["platformVersion"].split(".").splice(0, 2).join('.');
return +apiLevel;
const apiLevel = this.appiumCaps["platformVersion"] || this.appiumCaps["apiLevel"];
if (this.isAndroid && apiLevel) {
return apiLevel.split(".").splice(0, 2).join('.');
}
return apiLevel;
} catch (error) { }

return undefined;
}

Expand Down