Last active
March 20, 2020 16:00
-
-
Save titusfortner/f292cb8093f81f5fd57b3df2031fbe25 to your computer and use it in GitHub Desktop.
Defining Elements in Page Objects
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
@TagName("form") | |
private Element form; | |
@Id("user_email") @Scope("form") | |
private TextField email; | |
@Id("user_password") | |
private TextField password; | |
@Data("test=submit") | |
private Button submit; |
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
private Element form = browser.element(By.tagName("form")); | |
private TextField email = form.textField(By.id("user_email")); | |
private TextField password = browser.textField(By.id("user_password")); | |
private Button submit = browser.button(By.cssSelector("[data-test=submit]")); |
I'm somewhat amused that the Ruby dev is pushing for Typing and the Java dev is calling it not beneficial. :)
Yes, it's funny. :)
No, generally I love types. I only don't see any benefits of types in case of web elements.
They all have only two methods: click
and sendKeys
, that's why type doesn't matter for them.
Yeah, except SelectLists, and IFrames and RadioGroups and Forms and Input Fields and Date Fields.
And it isn't just about actions, it is about state (selected vs not selected); it is about information (selected value), etc.
A lot of code in Watir is managing these differences. Are they essential to being able to write tests? No. Are they beneficial? In my experience, yes absolutely.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh yes, I also ignore
@Scope("form")
annotation. Well, it's also easy: