-
-
Save titusfortner/f292cb8093f81f5fd57b3df2031fbe25 to your computer and use it in GitHub Desktop.
@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; |
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]")); |
Oh yes, I also ignore @Scope("form")
annotation. Well, it's also easy:
private SelenideElement form = $("form");
private SelenideElement email = form.$("#user_email");
private SelenideElement password = form.$("#user_password");
private SelenideElement submit = form.$(by("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.
When somebody suggests 2 options, I always assume that both are wrong, and seek a third one. :)
What about a shorter version?
You may argue that these are not typed elements, but let me ask what benefit this typyness really gives? Actually nothing. You can still call either
sendKeys
orclick
on those elements.