-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for Appium locate strategies. #3620
Add support for Appium locate strategies. #3620
Conversation
if (this.transport.api.isAppiumClient()) { | ||
locator = AppiumLocator.create(element); | ||
} else { | ||
locator = Locator.create(element); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can improve this by using Factory Pattern here.
class Locator {
create() {
console.log('Locator create called');
}
}
class AppiumLocator extends Locator {
create() {
console.log('AppiumLocator create called');
}
}
class NightwatchLocator {
static create() {
if (isAppiumClient()) {
return new AppiumLocator().create()
} else {
return new Locator().create()
}
}
}
// We can directly use this
NightwatchLocator.create()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this, because the main reason for creating a separate class for AppiumLocator
was to avoid passing a boolean flag (isAppiumClient
) to create()
method. /cc: @beatfactor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this would be ok, but the main issue is to check isAppiumClient() inside the locator class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check 4fd9c47.
This PR adds support for missing Appium locate strategies used to locate elements in native apps.