BrowserStack Summer of Learning is a free 5-part webinar series covering practical takeaways on test automation with Selenium and BrowserStack.
Each episode features experts who have implemented test automation successfully in Fortune 500 companies and contributed consistently to the open source ecosystem.
The series takes you from basic to advanced concepts in test automation, from setting up your first test scripts and the basics of Selenium to scaling your CI/CD pipelines and maintaining test hygiene at scale.
The first episode in the series, 'The Basics: Getting started with Selenium' took viewers through the basics of Selenium, setting up and writing their first test scripts, and picking the best frameworks for them.
Over the course of the episode, which was co-presented by David Burns (core contributor to Selenium) and Charlie Lee (Solutions Engineering Manager at BrowserStack), we received 80+ questions: about contributing to Selenium, structuring tests, testing builds with a VPN, and more.
In this post, David and Charlie answer the ones they couldn't address in the episode due to a lack of time.
How do you introduce Selenium testing to a small company with many small web projects?
I would start by making sure that you can get projects started quickly. This could be a template project that you fork for each little site. Create an abstraction, like the Page Object Model, to handle the sites. Soon, you will notice that some objects can be reused in each project. Move those into a template.
What's the best way to start structuring tests to ensure we have full coverage for our regression suite and is robust enough to allow for positive and negative testing?
Keep your tests short, independent, and focused. Aim for a large number of clear and concise tests.
Short: Each test should be 30-90 seconds long. This makes your tests much more agile and you can run more tests simultaneously to get your results back as quickly as possible. It also improves stability by reducing the number of long-running processes.
Independent: Do not keep dependencies (like a logged in user session) alive between multiple tests. Each test should be fully self-contained. This allows you to run one independently, in any order, without affecting the other tests.
Focused: Each test should focus on a single function. This makes result analysis much easier and reduces the number of variables contributing to a failing test. It will also prevent tech debt by keeping your test scripts simple and readable.
How does a Selenium grid make it possible to eliminate the "it's working on my mobile" issue? Can you give us some examples of how this would be used by a team of developers?
Unless the Selenium Grid only points at one person's machine, you will see mistakes (like missing items in a commit) when the tests are run on a CI/CD pipeline. Running tests on a selenium grid means you can get faster and you can run against browsers you don't have locally.
If my organization only allows me to test builds with a VPN, how could I use BrowserStack?
BrowserStack supports testing on applications accessible behind a VPN or firewall. This is possible using our Local Testing feature.
With BrowserStack Local Testing, you can securely test websites and apps hosted in your internal networks, local dev and staging environments.
How does BrowserStack automation differ from the normal automation we use on real browsers?
BrowserStack Automate is built on top of the Selenium Grid architecture, so your internal automation can be migrated to BrowserStack with minimal effort.
Potential changes in your scripts may include: adjusting timeouts and wait times to accommodate network conditions, updating capabilities to incorporate additional BrowserStack options, and ingesting the additional logs provided via BrowserStack's Automate dashboard and REST APIs.
Why is it that some visual regression tools cannot go through the Shadow DOM of Custom Elements?
Selenium can interact with these elements, but for the most part, it can only interact with the top level element. This is due to the way web components work in the browser.
How do we handle an authentication/login screen?
This would be like any part of a web application. Find the elements and interact with them. You are likely going to move those to some abstraction so that you don't have to log in with each test.
How do you suggest we handle pop-ups?
Selenium has good support classes that allow you to handle alerts and prompts. I suggest first using them if you're expecting a prompt and then handling them.
Do you have a documentation on how to run parallel testing without using DesiredCapabilities in Specflow?
Our Specflow documentation, including parallelization details, is available on our website and in this Github repo. While this documentation does include the DesiredCapabilties object, we also support the newer browser-specific capabilities like ChromeOptions.
If I’m writing scripts using Chrome for identifying locators for websites, can I run the test in mobile devices using the same script just by adding compatibilities?
It depends. Often, elements will have the same identifiers on both desktop and mobile browsers and you will be able to reuse the same test on both.
However, if your application is responsive and changes the HTML structure depending on the browser or resolution, you will need to account for this in your test.
For example, your site's header bar may show many links when viewed on a desktop browser, but on a mobile browser, it shrinks the links into a hamburger icon. In this case, your test will need an additional step of clicking the hamburger icon before selecting the desired header link.
Sometimes, as with timing issues, an issue is hard to spot in screenshots. Is there a way to capture video?
Yes. All Automate tests run on BrowserStack capture a video recording of the test by default. This video file can then be viewed in the BrowserStack dashboard or saved locally for permanent storage.
How do I start contributing to Selenium?
The best way is to check out Selenium code from GitHub, have a look at the issues and try to solve one of them. If you want to propose new features to the project, I suggest joining the Selenium Slack server and speaking to us. There might be reasons why we haven't implemented that idea in the past.