Book Image

Selenium 1.0 Testing Tools: Beginner's Guide

By : David Burns
Book Image

Selenium 1.0 Testing Tools: Beginner's Guide

By: David Burns

Overview of this book

<p>Selenium is a suite of tools to automate web application testing across many platforms. A strong understanding of using Selenium will get you developing tests to ensure the quality of your applications.</p> <p>This book helps you understand and use Selenium to create tests and make sure that what your user expects to do can be done. It will guide you to successfully implement Selenium tests to ensure the quality of your applications.</p> <p>The Selenium Testing Tools Beginner’s guide shows developers and testers how to create automated tests using a browser. You'll be able to create tests using Selenium IDE, Selenium Remote Control and Selenium 2 as well. A chapter is completely dedicated to Selenium 2. We will then see how our tests use element locators such as css, xpath, DOM to find elements on the page.</p> <p>Once all the tests have been created we will have a look at how we can speed up the execution of our tests using Selenium Grid.</p>
Table of Contents (18 chapters)
Selenium 1.0 Testing Tools Beginner's Guide
Credits
About the Author
About the Reviewers
Preface
Index

Chapter 11 – Getting started with Selenium 2


  • How do you use the WebDriverBackedSelenium?

    • Answer: Create a new instance of the browser you want to use using Selenium 2. Then pass this into the WebDriverBackedSelenium with the URL that you would like to test. It will look like this:

      @Before
      public void setUp(){
          driver = new FirefoxDriver();
          selenium =
            new WebDriverBackedSelenium(driver, http://book.theautomatedtester.co.uk)
      }
  • How do we start a browser for our tests to use?

    • Answer. We just need to instantiate it before our tests are expecting to use it, for example driver = new FirefoxDriver()

  • How does Selenium 1 and Selenium 2 differ in the way that it manages elements on the page?

    • Answer: In Selenium 1 we had to pass in the locator to an element in the API call. In Selenium 2 we need to find the element on the page with Selenium 2 and then interact with it

  • What happens when you find a hidden element and work with it?

    • Answer: Selenium 2 works very hard at trying to imitate what the user is likely to do. Selenium will find the hidden element but it will throw exceptions if you try to type or click on it

  • Are you still required to use Browserbot in your JavaScript?

    • Answer: No

  • To run the JavaScript, what do you need to do?

    • Answer: The code in the test needs to cast the driver to a JavascriptExecutor object and then call the execute method passing in the JavaScript snippet we would like it to execute

  • Can your JavaScript return to your test?

    • Answer: Yes

  • What does it return?

    • Answer: It returns a Plain Old Java Object (POJO) so that we can then cast it to the type that we need within our tests