18 Working with Browsers

A web browser is a software application that allows users to retrieve, present and traverse information resources on the World Wide Web (www). An information resource is identified by a Uniform Resource Identifier (URI). The information may be a web page, image, audio, video or any other content. There are various browsers available in the market as of now. These include internet explorer, chrome, firefox, safari, opera, etc. This chapter describes how to use the WebDriver method to simulate user actions on a firefox browser.

18.1.1| Introduction

  • Open Firefox Browser: WebDriver provided FirefoxDriver() class to open a new Firefox browser session. The following code shows how to create an instance of FirefoxDriver() and open the www.testinganswers.com site.
Open Firefox Browser

  • Open Chrome Browser: WebDriver provided ChromeDriver() class to open a new chrome browser session. The following code shows how to create an instance of ChromeDriver() and open the www.testinganswers.com site.
Open Chrome Browser

  • Open Internet Explorer Browser: WebDriver provided InternetExplorerDriver() class to open a new chrome browser session. The following code shows how to create an instance of InternetExplorerDriver() and open the www.testinganswers.com site.
Open Internet Explorer Browser


18.1.2| Choose a browser at run time

In Selenium WebDriver, we can automate test cases using Internet Explorer, Firefox, Chrome, etc browsers. Especially, in Cross Browser Testing. Cross Browser Testing is a type of functional test to check that your web application works as expected in different browsers. So, let's see, how to choose a browser at run time in Selenium WebDriver in below code piece

Choose a browser at run time


No comments: