-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Page Object Pattern Suggestion #179
Comments
I have, but in a closed source project. I now have a model like |
Thanks @DanielMSchmidt So if I look at the example https://github.com/wix/detox/blob/master/examples/demo-native-ios/e2e/example.spec.js And if I were to write a POM for this:
And PO file loginPage.js :
So when I tried this, its giving me an error saying 'element' is not found. How does the same work in spec file as there is no reference to element or by.label etc. |
Strange, element is exported when detox is initialized. Where does the po file live? |
So my folder structure is:
|
I don't get it, can you check your formatting maybe? |
How about now, I updated my previous comment. |
I think I was able to figure out. My export method was not correct. In my PO file:
And my spec file:
|
@kagalenitin |
@aamorozov I think you need to export the variable, only then you can access it. I am doing that using function, not sure if its the correct way to do it. |
@kagalenitin Yep that's exactly how i was doing that.. Not sure why it doesn't work though, is it passing for you? |
It works for me. |
@kagalenitin |
Nvm, got it working |
What was the issue? @aamorozov - Good to have it documented for future reference. Thanks. |
@kagalenitin So I ended up adding argument to function and passing there a var name for label:
where elem is const defined and imported from selectors.js |
My solution is something like: class LoginScreen {
get emailInput() {
return element(by.id("text-input-email"));
}
get passwordInput() {
return element(by.id("text-input-password"));
}
get loginButton() {
return element(by.text("Login & view cleans"));
}
typeEmail(email) {
return this.emailInput.typeText(email);
}
typePassword(password) {
return this.passwordInput.typeText(password);
}
tapLoginButton() {
return this.loginButton.tap();
}
} it("logs in a user", async() => {
const loginScreen = new LoginScreen();
await loginScreen.typeEmail('[email protected]');
await loginScreen.typePassword('password');
await loginScreen.tapLoginButton();
}); |
@lucassus , I tried your concept and got error as " Any idea, what mistake I am doing?
|
Just for the record, see my solution for above error. https://stackoverflow.com/questions/51356998/typeerror-loginscreen-visibleofwelcome-is-not-a-function |
Anyone tried any page object pattern library to use with detox? Any suggestions or example on how to approach this? Thanks in advance.
The text was updated successfully, but these errors were encountered: