Improving Your Web Applications with Selenium WebDriver
Sauce AI for Test Authoring: Move from intent to execution in proceedings.|xBack to ResourcesBlogPoste
Sauce AI for Test Authoring: Move from intent to execution in proceedings.
|
x
Blog
Improving Your Web Applications with Selenium WebDriver
Leverage Selenium WebDriver to automate part of your web coating testing approach.
Testing Login or Search seem straightforward. Click, case, click, type, wait, look. Something happens, though, between that initial trial of your first functionality and the final polished application, with many feature, across many browser and devices. Invariably things get reallycomplicated. Luckily, Selenium WebDriver can handle a lot of that complexity for you, if you leverage it correctly.
Historically, multi-platform deployment and robust testing have existed as natural enemies. Throughout the mid-2000s, software supplier simply insisted on support one single most-popular browser. Internal web applications were guaranteed only to work with Internet Explorer 6 on Windows XP. If you wanted to use Internet Explorer 7 when it arrive out, they made no warrant and helpdesk would not endorse the call. As for something exotic like upstart Firefox, forget about it.
Organizations didn & # x27; t do this to annoy their users; they be only trying to understate the cost of testing and support. That mouth to just how unmanageable and time-consuming examination web applications turn.
Eventually, the world adapted Internet Explorer & # x27; s dominance receded. Users demanded functionality in their browser of choice and reject to accept seriously crushed software. At the same clip, the bought phones and tablets and postulate the privilege of act (or shopping) while waiting in the Doctors office. The sponsoring executives, eagre to get more receipts and work hours, insisted the package see these demands.
The History of Selenium WebDriver
Forward-thinking developers did not just sit idle during this period of Internet Explorer dominance. Even as the web application testing conundrum slowed the rate of bringing, clever people sought ways to address it.
Developers atThoughtworks, specifically, had some ideas. While working on a web version of a clip and expense coating, Thoughtworker (and later, Sauce Labs co-founder) Jason Huggins built a tool that could obey encoded scripts. Selenium was born. Another Thoughtworker, Paul Hammant, built on this automation idea. He introduced a 2nd modality of operation for Selenium, that allowed remote & quot; steering & quot; of the functionality over TCP/IP. This meant that users coulddrivethe functionality utilise the programming language of their choice. Selenium therefore had two operating style: nucleus and remote-controlled (RC). This had powerful implications for testing. Selenium exploiter could now script interaction with browsers.
Selenium proceed to evolve By 2007, a competing designing emerged that would become know as WebDriver. Whereas Selenium 1.0 & # x27; s RC style worked via Javascript that ran in all browsers, the new design control via plugins that be “ close to the metal ” for each case-by-case browser. The project eventually merged Selenium with WebDriver and relinquish the merger as Selenium 2.0. WebDriver had replaced RC mode.
Selenium WebDriver as a De Facto Standard
As all of this growing took place, Selenium WebDriver create its way beyond the purview of Thoughtworks. Some of the original developer had locomote on and Thoughtworks open sourced the technology, so the existence have it by way of a public commission
As websites moved from brochures to full applications with societal elements, the world proceed to struggle with the problem of testing them. This problem alone grew worse with the rise of private-enterprise browsers, mobile technologies, and competing operating systems. Web application generator saw their conceptual ring-binder of examination instance grow exponentially.
Against this backdrop, Selenium WebDriver issue as a de facto criterion. As browsers multiplied, contributors could write plugins to indorse them. This allowed test automation to expand to new browser with a fraction of the effort. And, on top of that, Selenium users could automate with their language of choice. This lowered barriers to entry still further.
As many-browser support became the new reality, serious browser mechanisation meant Selenium WebDriver.
Selenium WebDriver Architecture
Let & # x27; s look in a bit more particular at just how this works such a broad exploiter groundwork. Selenium WebDriver boasts an architecture that create it incredibly extensible and flexible.
If you & # x27; ve execute any work in an object-oriented language, you & # x27; ve likely heard of the so-called& quot; mob of four & quot; design patterns. One of these is calledthe span form. Its description frequently sounds intimidating: decouple an abstract from its execution. But this is actually a evenhandedly simple, if powerful, concept. Think of light-colored replacement in your firm. The switch is your generalisation (or interface) and the light-colored turning on or off is the implementation.
You need to be capable to modify light bulbs without like whether you receive a push-button or rocker transposition. And you too want to be capable to change from a push button switch to a rocker without caring whether you have a yellowness or white light-colored bulb. You desire to do this to turn the light-colored bulb/light switch combination problem into an additive one alternatively of a multiplicative one. And Selenium WebDriver & # x27; s architecture act exactly the same way.
First, you have a collection of bindings symbolise your language choices for scripting (e.g. C #, Java, etc). Then you have a appeal of drivers representing the different browser. In the in-between sit the Web Driver API. You can now add bindings and browser driver severally, making for incredible depth of support. If some new browser arrive out and someone writes a driver for it, then citizenry using any binding can make use of it. Likewise, if someone adds a binding for a new programming language, they & # x27; ll immediately have use of all useable driver.
Let & # x27; s expression in a bit more detail at but how this works such a panoptic exploiter substructure. Selenium WebDriver boasts an architecture that create it incredibly extensile and flexible.
If you & # x27; ve done any work in an object-oriented language, you & # x27; ve likely heard of the so-called& quot; mob of four & quot; blueprint patterns. One of these is calledthe bridge pattern. Its description often sounds intimidating: decouple an abstraction from its implementation. But this is actually a jolly simple, if potent, construct. Think of light-colored switches in your firm. The switch is your abstract and the light become on or off is the implementation.
Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.
You need to be able to change light bulbs without caring whether you have a push-button or rocker switch. And you too want to be capable to change from a push button switch to a rocker without care whether you experience a yellowness or white light bulb. You want to do this to turn the light-colored bulb/light switch combination job into an additive one instead of a multiplicative one. And Selenium WebDriver & # x27; s architecture works exactly the same way.
First, you receive a collection of bindings representing your language choices for scripting (e.g. C #, Java, etc). Then you have a collection of drivers representing the different browsers. In the mediate sit the Web Driver API. You can now add binding and browser driver independently, making for unbelievable depth of support. If some new browser comes out and somebody writes a driver for it, then citizenry using any binding can make use of it. Likewise, if someone contribute a bandaging for a new scheduling language, they & # x27; ll immediately have use of all available drivers.
Consider an Example
Let & # x27; s see what this really looks like using a bit of code. For example purpose, I & # x27; ll use Java, but you can easy infer the mind here to your preferred language. The idea is just to showcase how one particular binding makes use of the API to allow easy use across different driver.
public void SeeWhatHappens () {
GoogleYourself (& quot; Joe Smith & quot;);
}
public void GoogleYourselfAcrossBrowsers (String name) {
GoogleYourself (name, new FirefoxDriver ());
GoogleYourself (gens, new InternetExplorerDriver ());
GoogleYourself (name, new ChromeDriver ());
}
public void GoogleYourself (String name, Driver driver) {
driver.get (& quot; http: //google.com & quot;);
}
It dwell of three different methods, with the first a trivial one to kick thing off. In that method, I call GoogleYourselfAcrossBrowsers and provide a pretty generic gens. GoogleYourselfAcrossBrowsers then invokes GoogleYourself using three different driver that it instantiates.
For its part, GoogleYourself does exactly that. And it allows you to see a bit of the API in action. Retrieve the homepage of google and then situate the & quot; q & quot; element (for query). Then send the keystrokes for the gens to that constituent and execute a submit, before quitting.
Taken as a whole, this code will Google the name in question using Firefox, Internet Explorer, and Chrome in sequence. Now, imagine a future in which some new browser comes out. You could add it to your tryout strategy by adding the appropriate driver dependency and then adding a single line of code.
The codification above is slenderly abstracted; it uses stenography for the new () methods to be readable. In praxis, the thought of pass in a browser and executing on what is pass in, or giving the name of the browser from the command-line, or any other method enables substantial reuse.
Code in Your Native Tongue
Traditional test mechanization has testers writing codification in some ‘ script ’ language,perhaps created by the vendor. Programmers compose their production code in C #, Ruby, Python, Java, or some other language and never see or stir the test code. Often the trial code is tail in some other system.
Writing the test code in the same lyric as the production code (or at least a language the product coder are smooth in) makes it possible for the product programmers to take some possession of the test codification. Placing it in the same version control system and putting the tests under continuous integration cantighten the feedback loopfrom weeks to find a regression defect to hour. Some team yet have maintenance for the tests that fail due to alteration as a obligation of the product programmers. Thus “ the narration isn ’ t perform until all the exam run. ”
Rethinking Your Test Strategy
If you & # x27; ve lived without this form of exam mechanisation, hopefully, you & # x27; re starting to read its power. You might experience tests at the unit level, and perhaps you & # x27; re got an automated system and consolidation tests as well. But, without Selenium WebDriver, there & # x27; s a good chance you & # x27; re not automating at the top of thetesting pyramid.
If you aren ’ t experiencing this power so you ’ re probably doing this manually. And, in the domain of web covering and multiple versions of multiple browsers across multiple devices, you & # x27; re plausibly perform a lot of highly insistent examination. Or, if you & # x27; re not, then you & # x27; re probably taking an awful lot on faith.
With Selenium WebDriver, you can really direct a serious screen spot in your testing strategy. Handing QA a gigantic binder full of insistent test cases and inquire them to control with every freeing creates mind-numbing work better spent on other thing. It & # x27; s a bad investment that finds shocking few defects for the money.
Consider leverage Selenium WebDriver to automate this part of your testing approaching, particularly since it bring itself quite well to automation. Free QA up to focus more on explorative testing and other coming that involve more human judgment.
Selenium WebDriver Use Cases
Let & # x27; s now get a bit more concrete about actual use cases for Selenium WebDriver. Hopefully, you understand now that it can give your testing strategy a makeover, while make it lots more comprehensive. But let & # x27; s expression, in general, at what you can do with a web automation framework.
Reuse GUI testing across a multitude of browsers.
Perform core regression test several times a day.
Generate a rattling seeable display of functional or acceptation testing for your application. Stakeholders can actuallywatchthe trial run.
Improve coordination between developers and testers.
Create system demonstration as a no-cost by-product of the test process, that can also function as certification for “ expected behavior. ”
As you can see, squawk up your testing strategy features most prominently. This form of automation can help with fixation, functional, and acceptance examination. But you can also realise a duo of additional perks. In order to get good at automatise use of the GUI, you need to develop an in-depth agreement of the GUI & # x27; s elements. Testers and those execute testing as an activity will understand what is happening “ under the hoodlum ”, for example how APIs and Javascript interact. And, you can use the automation to demo functionality both to a product owner and to end-users or other stakeholders.
You can belike come up with extra value in your unique situation that I haven & # x27; t listed hither. This is a knock-down tool.
Improving Your Web Applications
Overall, this adds up to get improving your web coating and make your store good at what it does. We & # x27; ve come a long way since the day of Internet Explorer 6 dominating the grocery. Browsers have proliferated and people have more choices than always, while experience higher expectations than ever before. You can differentiate yourself by continue up with that proliferation while present high-quality web covering. But you can & # x27; t do that without help. You need tools in your tool belt, and Selenium WebDriver is one of the most knock-down unity out there.
Share this spot
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