Started learning Selenium Webdriver with Java for UI automation. Are there good Git repositories with projects that I can clone and look at for good coding practices used?

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.

Appreciate all the help!

2 Likes

There are a bunch of example tests in the selenium GitHub repository. I haven’t checked them yet as also just started -

2 Likes

Also keep your eye out for Selenide. We have migrated our old Selenium tests to use it.

2 Likes

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.

1 Like

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!

1 Like

Hi

Not sure this helps - GitHub - vishnuar/java-selenium-page-object-framework

It is a POM framework and integrated with Gradle. Let me know if you have any questions

Thanks
Vishnu

2 Likes

How are you finding Selenide? I saw it demoed in a webinar and thought it looked pretty nice

1 Like

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).

1 Like

Given I only begun venturing into UI automation, can you please elaborate reasons why you are not a fan of Selenium or Java?

1 Like

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.

1 Like

(post deleted by author)

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.

Today, I would use Playwright with Node.

1 Like

Java boilerplate is a general language issue for non-java programmers.
Selenium Java is working ok for me for now, but early days

1 Like

Of course it works, otherwise Selenium Java wouldnt be a thing :slightly_smiling_face:

I am not sure what point you are making here though:

1 Like

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.

1 Like

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.

1 Like

I often use JavaScript but prefer to avoid it. The no-code 'record and playback ’ systems didn’t work for me, so I’m left with selenium java

Yahoo Mail: Search, Organize, Conquer

I am not sure why you think your choices are so limited.

For example, Playwright supports JS, Python, Java and C#. I would not touch record and playback systems with a 10 decillion foot bargepole.

I’ll take a look at playwright, thanks

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