TesterHQ - The Evil Tester Blog Aggregator

Aug 3, 2012 - 3 minute read - Selenium Simplified Blog WebDriver

Sporting Event Tribute Using Selenium WebDriver

Original Blog Posting on [SeleniumSimplified.com]

As I write this, the capital city of England currently hosts a large sporting event. I can mention no names nor dates, for that sequence of words forms part of the protected thou shalt not use list. I don’t even know if ‘they’ will allow me to link to that page.

Regardless, I created a small test app which pays tribute to sporting events through the years.

 

Since I grew up in the 80s, programming on ZX Spectrums, I have a fondness for scrolly text that judders. I decided to replicate this effect using the browser title and hacking in my own text, overwriting the official text in page element.</p> <pre>((JavascriptExecutor)driver).executeScript("document.title='" + displayBanner + "'");</pre> <p> </p> <p>I don’t do this a lot when writing automated tests, but I have to confess - I don’t let the application functionality stopping me testing it. So I do sometimes force elements to be visible so that I can access them through automation. I mainly do this for exploratory automation work.</p> <p>If you have never done this before then I shall recommend now that you try it. Rule nothing out in your hunt for test automation effectiveness.</p> <p>I primarily wrote this little script to experiment with the WebDriver window positioning commands:</p> <ul> <li>(WebDriver) .manage().window.setSize</li> <li>(WebDriver) .manage().window().getPosition()</li> <li>WebDriver) .manage().window().setPosition()</li> </ul> <p>The listing from the video is below:</p> <pre>@Test public void bounceThatWindow(){ WebDriver driver = new FirefoxDriver(); driver.get("file://" + System.getProperty("user.dir") + "/jsrunner.html"); driver.manage().window().maximize(); Dimension fullScreenSize = driver.manage().window().getSize(); int changeWidth = 200; int changeHeight = 210; int xDir = 8; int yDir = 8; int xDirIncrement = xDir; int yDirIncrement = yDir; driver.manage().window().setSize(new Dimension(changeWidth,changeHeight)); Point position = driver.manage().window().getPosition(); String banner = "***BANG****........ AND THEY ARE OFF........ Automation can be fun. " + " EvilTester.com present a javascript and browser" + " animation using Selenium 2 WebDriver tribute to the" + " sporting event that cannot be named lest we be sued"; int bannerStart = 0; for(int bounceIterations = 0; bounceIterations < 1000; bounceIterations ++){ position = position.moveBy(xDir,yDir); driver.manage().window().setPosition(position); if(position.getX()>(fullScreenSize.getWidth() - changeWidth)){ xDir = -1 * xDirIncrement; } if(position.getX()<0){ xDir = xDirIncrement; } if(position.getY()>(fullScreenSize.getHeight() - changeHeight)){ yDir = -1 * yDirIncrement; } if(position.getY()<0){ yDir = yDirIncrement; } String displayBanner = banner.substring(bannerStart,bannerStart+30); ((JavascriptExecutor)driver).executeScript("document.title='" + displayBanner + "'"); bannerStart++; if(bannerStart > banner.length()-35){banner += banner;} } driver.quit(); }</pre> <p>Since I only planned to let the demo run for a short period of time you can see that I just let the banner string extend and extend and extend by continually appending the text to it. Seemed like a nice sensible shortcoming given the nature of the demo. Just a warning to you in case you decide to put this into a loop for an hour or so.</p> <p>You can find the full source listing at <a href="https://github.com/eviltester/webDriverExperiments/" target="_blank">https://github.com/eviltester/webDriverExperiments/</a></p> <p>Specifically <a href="https://github.com/eviltester/webDriverExperiments/blob/master/src/test/java/com/seleniumsimplified/webdriver/sports/SportsEventTributeTest.java" target="_blank">here</a>.</p> <p>The ascii animation was created using <a href="http://asciimator.net/" target="_blank">asciimator.net</a></p> <p>A fun extension, should you want a challenge, would be to create 3 windows, size them, and then have WebDriver play a game of <a href="http://en.wikipedia.org/wiki/Pong" target="_blank">PONG</a> with them.</p> <p>Enjoy.</p> </div> <footer> <p class="meta"> <span class="byline author vcard">Posted by <span class="fn">Alan Richardson</span></span> <time>Aug 3, 2012</time> </span> </p> <p class="meta"> <a class="basic-alignment left" href="http://testerhq.com/post/blogs/seleniumsimplified/2012-06-15-second-edition-of-selenium-simplified-is-out/" title="Second Edition of Selenium Simplified is out">Second Edition of Selenium Simplified is out</a> <a class="basic-alignment right" href="http://testerhq.com/post/blogs/seleniumsimplified/2012-08-03-a-minimal-webdriver-based-dsl/" title="A minimal WebDriver based DSL">A minimal WebDriver based DSL</a> </p> </footer> </article> </div> <aside class="sidebar thirds"> <section class="first odd"> <h1>Evil Tester HQ</h1> <p> This is the aggregated set of posts for Alan Richardson from all of his blogs. Alan works as an <a href="http://compendiumdev.co.uk/page/consultancy" target="_blank">independent consultant</a>, helping companies improve their use of automation, agile, and exploratory technical testing. <br/><br/>Alan Richardson has performed <a href="http://compendiumdev.co.uk/page/conferences" target="_blank">keynote speeches and tutorials at conferences</a> worldwide. Author of the books ‘<a href="http://compendiumdev.co.uk/page/deareviltester" target="_blank">Dear Evil Tester</a>’, ‘<a href="http://compendiumdev.co.uk/page/javafortestersbook" target="_blank">Java For Testers</a>’ and ‘<a href="http://compendiumdev.co.uk/selenium/" target="_blank">Selenium Simplified</a>’. <br/><br/>Alan also has created <a href="http://compendiumdev.co.uk/page/online_training" target="_blank">online training courses</a> to help people learn <a href="http://compendiumdev.co.uk/page/techweb101course" target="_blank">Technical Web Testing</a> and <a href="http://compendiumdev.co.uk/page/seleniumwebdrivercourse" target="_blank">Selenium WebDriver with Java</a>. <br/><br/>Alan posts his writing and training videos on <a href="http://SeleniumSimplified.com" target="_blank">SeleniumSimplified.com</a>, <a href="http://EvilTester.com" target="_blank">EvilTester.com</a>, <a href="http://JavaForTesters.com" target="_blank">JavaForTesters.com</a>, and <a href="http://CompendiumDev.co.uk" target="_blank">CompendiumDev.co.uk</a>. </p> </section> <ul class="sidebar-nav"> <li class="sidebar-nav-item"> <a target="_blank" href="https://github.com/eviltester" title="https://github.com/eviltester"><i class="fa fa-github fa-3x"></i></a> <a target="_blank" href="https://twitter.com/eviltester" title="https://twitter.com/eviltester"><i class="fa fa-twitter fa-3x"></i></a> <a target="_blank" href="https://www.linkedin.com/in/eviltester/" title="https://www.linkedin.com/in/eviltester/"><i class="fa fa-linkedin fa-3x"></i></a> <a target="_blank" href="https://www.facebook.com/eviltester/" title="https://www.facebook.com/eviltester/"><i class="fa fa-facebook fa-3x"></i></a> <a target="_blank" href="https://www.youtube.com/user/EviltesterVideos" title="https://www.youtube.com/user/EviltesterVideos"><i class="fa fa-youtube fa-3x"></i></a> <a target="_blank" href="https://www.instagram.com/eviltester/" title="https://www.instagram.com/eviltester/"><i class="fa fa-instagram fa-3x"></i></a> </li> </ul> <section class="odd"> <li> <a href="http://testerhq.com/categories/evil-tester" title="Evil Tester Blog" >Evil Tester Blog</a> </li> <li> <a href="http://testerhq.com/categories/java-for-testers" title="Java For Testers Blog" >Java For Testers Blog</a> </li> <li> <a href="http://testerhq.com/categories/compendiumdev" title="Compendium Developments News" >Compendium Developments News</a> </li> <li> <a href="http://testerhq.com/categories/selenium-simplified-blog" title="Selenium Simplified Blog" >Selenium Simplified Blog</a> </li> <li> <a href="http://testerhq.com/categories/linkedin" title="Linkedin Posts" >Linkedin Posts</a> </li> <li> <a href="http://testerhq.com/categories/instagram" title="Instagram Posts" >Instagram Posts</a> </li> <li> <a href="http://testerhq.com/categories/quora" title="Quora Answers" >Quora Answers</a> </li> </section> <section class="even"> <h1>Recent Posts</h1> <ul id="recent_posts"> <li class="post"> <a href="/post/blogs/eviltester/2018-06-11-on-shift-left/">Notes on Shift Left in Testing and Software Development</a> </li> <li class="post"> <a href="/post/blogs/seleniumsimplified/2018-06-06-os-selenium-migration-book/">Open Source Selenium Migration book</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-06-01-the-question-testing-super-heroes/">The Question - Are there any Software Testing super heroes?</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-05-30-google-advanced-search-dork/">Google Advanced Searches - Google Dorks</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-05-15-on-hacking-and-being-hacked/">On Hacking and Being Hacked</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-05-09-protect-the-square-and-buggy-games/">Protect The Square and Buggy Games</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-05-08-counterstring-algorithms/">CounterString Algorithms</a> </li> <li class="post"> <a href="/post/blogs/javafortesters/2018-05-06-some-similarities-between-java-and-javascript/">Some Similarities Between Java And JavaScript</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-05-04-management-restricts-testing/">When Management Systems Restrict Testing - Crowdsourced Functional and Security Testing Mismatch</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-05-03-eviltester-show-rejection/">The Evil Tester Show - Episode 005 - Rejection</a> </li> <li class="post"> <a href="/post/blogs/javafortesters/2018-04-26-overview-of-spark-java-webserver-testing/">Overview of Spark and HTTP Testing with JUnit</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-04-26-eviltester-compendium-of-testing-apps/">A Compendium of Testing Apps</a> </li> <li class="post"> <a href="/post/blogs/javafortesters/2018-04-25-when-basic-http-and-when-rest-assured/">When would I choose basic HTTP libraries rather than using RestAssured?</a> </li> <li class="post"> <a href="/post/blogs/javafortesters/2018-04-24-migrating-from-jaxb-xml-to-xstream/">Migrating from JAXB XML processing to XStream</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-04-12-installing-automating-testing-rest-api-code/">How to use the Source Code for the Book Automating and Testing a REST API</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-04-12-how-to-use-the-test-practice-pages/">How to use Test Practice Pages and Games from Evil Tester</a> </li> <li class="post"> <a href="/post/blogs/javafortesters/2018-04-09-restassured-java-1-9-xml/">Changes to Automating a REST API code base for Java 1.9</a> </li> <li class="post"> <a href="/post/blogs/javafortesters/2018-04-08-exploratory-programming-for-learning/">How to learn Java with Exploratory Programming</a> </li> <li class="post"> <a href="/post/blogs/lists/2018-04-01-which-bags-and-cables-for-macbook-pro/">Which MacBook Pro Cables, Adapters and Bags should you buy?</a> </li> <li class="post"> <a href="/post/blogs/inthenews/2018-03-31-in-the-news/">Software Testing News - 21st March 2018 to 31st March 2018</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-03-29-installing-curl-on-windows/">How to install cURL on Windows</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-03-23-using-turnkey-linux-vm-for-tracks-testing/">Using the Turnkey Linux VM for Tracks Testing</a> </li> <li class="post"> <a href="/post/blogs/inthenews/2018-03-20-in-the-news/">Software Testing News - 15th March 2018 to 20th March 2018</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-03-20-acceptance-testing-fizzbuzz-java-junit/">Automated Execution for Acceptance Testing - Java JUnit FizzBuzz</a> </li> <li class="post"> <a href="/post/blogs/inthenews/2018-03-15-in-the-news/">Software Testing News - 8th March 2018 to 15th March 2018</a> </li> <li class="post"> <a href="/post/blogs/inthenews/2018-03-08-in-the-news/">Software Testing News - 2nd March 2018 to 8th March 2018</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-03-04-tdd-fizzbuzz-java-junit/">TDD - Test Driven Development - Java JUnit FizzBuzz</a> </li> <li class="post"> <a href="/post/blogs/inthenews/2018-03-02-in-the-news/">Software Testing News - 26th Feb 2018 to 2nd March 2018</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-03-02-practice-testing-session-button-game/">A practice exploratory testing session - javascript button game</a> </li> <li class="post"> <a href="/post/blogs/lists/2018-02-26-top-ten-web-testing-categories/">Top 10 Web Software Testing Tool Categories to improve your testing</a> </li> <li class="post"> <a href="/post/blogs/inthenews/2018-02-26-in-the-news/">Software Testing News - 19th Feb 2018 - 25th Feb 2018 -</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-02-23-problem-solving-as-software-development/">Problem Solving as Software Development</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-02-21-career-in-software-testing/">Considering a Career in Software Testing?</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-01-16-promoting-evil-tester-talks/">Promoting Evil Tester Talks Conference Talk and Webinar Archive</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-01-12-testability-vs-automatability-in-theory/">Testability vs Automatability - in theory (Free Bonus Video Inside)</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2018-01-04-the-evil-tester-show-004/">The Evil Tester Show - Episode 004 - New Year 2018</a> </li> <li class="post"> <a href="/2017/12/24/poc-vs-mvp/">Proof of Concept vs Minimum Viable Product</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2017-12-18-automating-javascript-storify-twitter/">Automating Storify and Twitter Using JavaScript From the Dev Tools</a> </li> <li class="post"> <a href="/post/blogs/javafortesters/2017-12-07-resource-files-for-tests/">How to organise resource files for tests using Maven and Java</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2017-11-27-what-is-agile-testing-the-books/">What is Agile Testing? The Books List</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2017-11-24-the-evil-tester-show-003/">The Evil Tester Show - Episode 003 - Black Friday Special</a> </li> <li class="post"> <a href="/2017/11/21/allow-candidates-to-shine/">Allow your best candidates to shine. Interview over the phone. Audition face to face.</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2017-11-17-the-evil-testers-guide-to-agile-001-what-is-agile/">What is Agile Testing? The Evil Tester's Guide To Agile</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2017-11-16-the-evil-testers-guide-to-agile-slides/">The Evil Tester's (Mini) Guide To Agile</a> </li> <li class="post"> <a href="/2017/11/14/recruit-people-not-fulfil-roles/">Recruit People, Don't Fulfil Roles</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2017-11-10-the-evil-tester-show-002/">The Evil Tester Show - Episode 002 - Provocative Therapy</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2017-11-09-a-treatise-of-buggs/">A Treatise of Buggs</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2017-10-27-the-evil-tester-show/">Announcing The Evil Tester Show - Podcast</a> </li> <li class="post"> <a href="/post/blogs/eviltester/2017-10-24-what-is-regression-testing/">What is Regression Testing? Software Testing FAQs and Definitions</a> </li> <li class="post"> <a href="/post/blogs/javafortesters/2017-10-13-maven-local-dependencies/">Simple ways to add and work with a `.jar` file in your local maven setup</a> </li> </ul> </section> </aside> </div> </div> <footer role="contentinfo"> <p>Copyright © 2018 Alan Richardson - <a href="https://www.compendiumdev.co.uk/page.php?title=privacy">Privacy Policy</a> | <a href="https://www.compendiumdev.co.uk/page.php?title=contact_us">Contact Us</a> </p> </footer> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-40223273-6', 'auto'); ga('set', 'anonymizeIp', true); ga('send', 'pageview'); </script> <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=95a37ca4-4500-4277-a60b-a3ad533f36d9"></script> </body> </html>