I’ve been trying to expand my skillsets by learning UI automation and picked Selenium Webdriver and JAVA since my current company already has an automation framework for it.
While I am learning from self paced courses and through the help of some co-workers, I also want to look at Git repositories that others might have to help expose myself to how others organize their code and design scripts.
Selenide does waiting (I just read)
Doesn’t selenium Webdriver deal with
waiting ?
I tried selenium IDE first and the main problem was not waiting. Only way I could make it run was to use breakpoints at every step.
I looked at running .side scripts with Selenium side runner but:
it fails to read cookies, also it doesn’t wait.
There’s a command something like: waitTillElementVisible but that didn’t help.
I am not a great fan of Selenium. There are better, more recent, tools. If you have to use Selenium, I would put Geb in front of it. But, I would not use Java for testing either!
We switched our Selenium tests over to Selenide over a year ago. We prefer the readability and wait feature, for example: $("#logInBtn").shouldBe(visible, Duration.ofSeconds(10)).click();
waits for up to 10 seconds (but clicks button if it’s visible in 1 second).
Sure. Selenium is just too heavyweight and in many ways suffers from its age.
My objections to Java are not specific to Java. It’s more about the design of Java being hardwired for production code. So test code requires workarounds which can be avoided in scripting languages - for example, JS or Groovy.
They are two separate things. For Java (and from what I have seen, it is the same in C#), the issue is that everything has to be in a class. It causes so much useless boilerplate code and potentially repeated content. Examples below are for Cucumber.
Java:
public class Example
{
@Given("I am on the login page")
public void i_am_on_the_login_page() {
// Implementation
}
}
Groovy:
Given ("I am on the login page") {
// Implementation
}
This is a very small example, but you get the point.
Years ago, I used Selenium but with a Groovy library in front of it, which had the page object model integrated into it. This is no longer maintained, but have a look at gebish.org.
I tried other things but they didn’t work for me: Selenium IDE, then Selenium SideRunner, TestRigor.
Your point about java boilerplate is not specific to Selenium is it ? People who use java most of the time see right through the boilerplate: most of it is easily created with an IDE and some copy-pasting.
It does genuinely puzzle me that new people are still picking up Selenium, when better tools are available. I suppose I get it if there is an existing Selenium code base that they need to add to, but being part of a quality strategy for greenfield seems odd to me.
As for Java boilerplate, I guess if people are happy to work around a language’s deficiencies, that’s up to them. I’d rather avoid the cognitive load and not force my brain into having to process valueless text. I prefer simplicity.
So Playwright codegen does record to code, no playback. Are the locators reliable ? the other recorders I tried were some help but usually I ended up getting an xpath from devtools.
Last problem I had today was normally codegen starts on pause() but this doesn’t happen when browser is set to use chrome user data ( for cookie reading)
Any ideas ? thanks