forked from nightwatchjs/nightwatch
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix visible commands for Appium. (nightwatchjs#3566)
- Loading branch information
1 parent
5ef19c6
commit 65b2055
Showing
10 changed files
with
274 additions
and
15 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
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,31 @@ | ||
const {By, RelativeBy} = require('selenium-webdriver'); | ||
|
||
const LocateElement = require('./locator.js'); | ||
const {AVAILABLE_LOCATORS} = LocateElement; | ||
|
||
class AppiumLocator extends LocateElement { | ||
/** | ||
* @param {object|string} element | ||
* @return {By|RelativeBy} | ||
*/ | ||
static create(element) { | ||
if (!element) { | ||
throw new Error(`Error while trying to locate element: missing element definition; got: "${element}".`); | ||
} | ||
|
||
const byInstance = LocateElement.locateInstanceOfBy(element); | ||
if (byInstance !== null) { | ||
return byInstance; | ||
} | ||
|
||
const elementInstance = LocateElement.createElementInstance(element); | ||
|
||
if (elementInstance.locateStrategy === 'id') { | ||
return new By(elementInstance.locateStrategy, elementInstance.selector); | ||
} | ||
|
||
return By[AVAILABLE_LOCATORS[elementInstance.locateStrategy]](elementInstance.selector); | ||
} | ||
} | ||
|
||
module.exports = AppiumLocator; |
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
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
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
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
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
Oops, something went wrong.