QABot
Get started with QABot
  • rss
  • archive
  • Use Selenium to monitor web applications

    The are no doubts about benefits of regression and automated testing. Lately browser automated tests are becoming even more popular and one of the leaders in this area is Selenium (seleniumhq.org), an open-source testing tool that’s using real web browsers to perform your tests.

    Here is a simple JUnit test that is checking home page’s title.

    public class Example1Test {
        private WebDriver wd;
    
    	@Before
    	public void before() {
    		wd = new FirefoxDriver();
    		wd.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    	}
    
    	@Test
    	public void test_title() {
    		wd.get("http://example.com");
    		assertEquals("Welcome to exemple.com!", wd.getTitle());
    	}
    	
    	@After
    	public void after() {
    		wd.close();
    		wd.quit();
    	}
    }
    

    This is a basic Selenium test, but does quite a few things. It will open Firefox browser, navigate to example.com, assert the title and if it doesn’t match junit will fail and let you know where. Usually you’d run tests like this in your continuous integration setup, after each build and deployment. This is a good practice, but I think we can go even further and run these tests continuously, as part of continous regression testing setup, against production web apps. How often it’s up to you, but the more tests you have the more chances to prevent some issues that occur only in production. One thing to mention is that if you’re using Google Analytics, you have to make sure that Selenium tests don’t mess up your stats, you can though avoid that*

    At QABot, we’re running our smoke tests every 15 minutes, which include checking if ToS, Privacy and Contacts pages are available, but we’re not stopping here, we’ll be adding more tests once we have more functionality and more content.

    * - http://support.google.com/analytics/bin/answer.py?hl=en&answer=1034840

    • March 8, 2013 (10:49 am)
    • 1 notes
    • #selenium
    • #synthetic monitoring
    • #active monitoring
    1. innovez reblogged this from qabot
    2. qabot posted this
© 2013 QABot