Pages

Wednesday, September 1, 2010

Simulating Browser Back button

  static SeleniumServer server;
    static Selenium selenium;
    public void testBrowserBackButton() throws InterruptedException
    {
        //Start the server
        try {
            server.start();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.out.println("Failed to start the server");
            e.printStackTrace();
        }
        //Stop the server
        server.stop();
      
        //Start the selenium session
        selenium = new DefaultSelenium("localhost",4444,"*firefox","http://www.google.com");
        selenium.start();
        selenium.open("");
       
        //Click on Advanced Search Link
        selenium.click("link=Advanced Search");
       
        //Click on Back Button to go back to Google Search page
        selenium.goBack();
       
        //Stop & close the selenium browsers
        selenium.close();
        selenium.stop();
    }

No comments:

Post a Comment