Speed Up Your Selenium Tests
Sauce AI for Test Authoring: Move from intent to execution in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from intent to execution in minutes.
|
x
Blog
Speed Up Your Selenium Tests
Tips and Tricks for hotfoot up your Selenium Tests
Automated browser trial are wonderful, almost as wonderful as fast-running build systems. Once we add the two together to create uninterrupted integration, they seem to be at odd. We all go through it, even here at Sauce. So here are a few things we & # x27; ve found to actually help speed up Selenium testing:
1) Parallelism
If all tests run in less than ten minutes separately, and it is possible to put each examination on a different machine, then the entire examination run should be ten second or less … flop?
Sadly, things don ’ t happen that way oft enough. Generally, that is because of the design. hen writing your tests, always ask yourself, & quot; Can I run this test by itself and have it pass? & quot; If you opine to yourself, & quot; No ... another test has to run * before * for this one to pass, & quot; thenstop. Put the shovel down, and get climbing your way out of that hole. Tests that rely on previous tests cause intermittent issues, are difficult to run when you require to reproduce those bugs, and are simplyslow.So continue your tests independent. It & # x27; s how they were meant to be anyway.
When none of your tests are interdependent, that means they can all be run in analogue, with the entire test run taking as long as the longest test. Which brings us to our next point.
2) Short Tests
Write your tests to only test a single bantam bit of functionality. As a rule of thumb, hold the number of steps in your tests under 20. All the parallelism in the world won & # x27; t save you from long-running tests,because a individual test can & # x27; t be parallelized. As another prescript of thumb, e the best-written tests we & # x27; ve seen generally run inunder 10 seconds.
Yes, that is little. If you & # x27; re wondering how that & # x27; s possible, check out pace # 3, below.
For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.
A pleasant side-effect of this is that when a frame betray, you & # x27; ll be able to specialize it down to a real specific region point and fix it all the faster.
3) Pre-populate the cookies
Every browser you get from Sauce Labs is in a clean state. This is outstanding, and you really want this. Even if Fred says you don & # x27; t want it, you want it. Tell Fred, & quot; Fred, last night I spent an hr debugging tests, and launch out nothing was wrong. You know what the problem was? Someone had installed the fuzzy_warm_critters_asciis browser propagation, and it replaced every instance of my javascript with an ASCII cat. I want unclouded browsers every time. & quot; Do it. Fred will understand.
This model a bit of a problem with shorter builds, because now each browser session has to go through a login process, and possibly a few more steps depending on your application logic, just to get to where you want to test. Previously, I but recommended abstracting the login process into a separate method so that the tests looked cleaner, but when you & # x27; re waiting for the build to finish, that & # x27; s not full plenty. You desire them light * and * fast. One way to get this is to set the cookie via Selenium after the browser commence up.
Log in to your user via server-side logic (e.g., generate a row in your sessions table, or however you have it setup topically), yield a cookie for that login session, and push it into the browser via Selenium. Bam. You & # x27; re done logging in, and your trial can continue on as though it had already spent the 5 seconds logging in and the 10 mo add items to the shopping go-cart, all so you can only test the & quot; confirm purchase & quot; button work on your site as look in Edge.
This isn & # x27; t to say that you shouldn & # x27; t test out your login sort or your & quot; add fuzzy critter to cart & quot; logic via browser tests. Because you should. But you shouldn & # x27; t do itfor every test. Test it once, try it good, and leave it at that.
This works on anything that relies on state to be built up. Logins, Shopping Carts, Playlists, etc. You get a clean browser for every tests, and your tests are quick. And you know what? Even Fred will love it. And that - in and of itself - is worth it.
Got any tips on how you quicken up your Selenium builds? Take us to school and share & # x27; em. We & # x27; re all ears! Oh, and for Fred & # x27; s sake ...
|\ _,,, -- -, ,_
/, ` .- & # x27; ` & # x27; -.; -;;, _
|,4-)) -, _ ..; \ (` & # x27; - & # x27;
& # x27; -- - & # x27; & # x27; (_/ -- & # x27; ` - & # x27; \_)
SAUCE LABS - SELENIUM AND APPIUM TESTING IN THE CLOUD
The Sauce Labs cloud-based testing program allows developer to automatically or interactively test mobile and web covering on 100 of browsers and platforms include iOS, Android & amp; Mac OS X. With built-in video recording of every test, debugging tools, and secure tunneling for local or firewalled testing, Sauce makes running, debugging and scaling exam suites easier than always. Sauce supports automated functional testing with Selenium and Javascript unit testing in all the popular programming speech, framework and CI systems.
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free