Start your learning by reading the user guide
I see daily a lot of Selenium Java code published on the internet.
All of it presented as showcasing good practices.
Just a few examples:
use Page Factory as a model for structuring your Selenium code
upload files using Robot class or AutoIt
download files
retry tests if they are flaky
use methods that wait until the page is loaded
re-use the browser by multiple tests with BeforeClass/AfterClass test fixtures
create test data through the UI with Selenium tests
break very long tests in multiple smaller and dependent tests
automate CAPTCHA
use GMAIL accounts
use assertions in page methods
use implicit waits
etc
Every time I see something like this (usually in a post written by an expert), I remember about the most ignored guideline to follow.
The user guide published by the Selenium team.
Most people ignore it and follow instead advice like the one from above.
Which is so wrong.
Why is it wrong?
Let’s see.
1. Page Factory
This is the page with the recommended models by the Selenium team.
Can you find any reference to Page Factory in it?
No?
Why do you think that it is not included?
2. Download Files
The Selenium API does not have any way of monitoring a file download.
But if you insist on doing it, at least follow the guideline.
3. Re-use the browser by multiple tests
The Selenium team says clearly that you should use a fresh browser per test.
4. Create test data through the UI with Selenium tests
Selenium should not be used to prepare a test case or test data.
5. Break very long tests in multiple smaller and dependent tests
Sorry, tests should be independent.
6. Automate CAPTCHA
Do not automate this as it is not possible.
Instead, ask the dev team to disable it on test environment.
7. Use GMAIL accounts
8. Use assertions in page methods
Use assertions only in test methods.
I could go on but probably you get the point.
Read the user guide first.
Follow the advice of the Selenium team.
Thanks for reading.