Presentation is loading. Please wait.

Presentation is loading. Please wait.

Selenium server By, Kartikeya Rastogi Mayur Sapre Mosheca. R

Similar presentations


Presentation on theme: "Selenium server By, Kartikeya Rastogi Mayur Sapre Mosheca. R"— Presentation transcript:

1 Selenium server By, Kartikeya Rastogi Mayur Sapre Mosheca. R
Rajalakshmi Sankar Shiny Richard. V Sweta Bansal 31 – October 1

2 INTRODUCTION TO SELENIUM
Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. It is quite similar to HP Quick Test Pro (QTP) only that Selenium focuses on automating web-based applications. Selenium is not just a single tool but a suite of software , each catering to different testing needs of an organization. It has four components (i) Selenium Integrated Development Environment (IDE) (ii)Selenium Remote Control (RC) (iii) Selenium Web Driver (iv)Selenium Grid 2

3 SELENIUM SUITE In future, Selenium RC and Web Driver are merged into a single framework to form Selenium 2. Selenium 1, by the way, refers to Selenium RC. 3 3

4 SELENIUM SERVER Selenium Server receives Selenium commands from our test program, interprets them, and reports back to our program the results of running those tests. Selenium-Core is a JavaScript program, actually a set of JavaScript functions which interprets and executes Selenese commands using the browser’s built-in JavaScript interpreter. The RC server bundles Selenium Core and automatically injects it into the browser. This occurs when your test program opens the browser (using a client library API function). The Server receives the Selenese commands from our test program using simple HTTP GET/POST requests. We can use any programming language that can send HTTP requests to automate Selenium tests on the browser. 4

5 RUNNING SERVER Before starting any tests we must start the server. Go to the directory where Selenium RC’s server is located and run the following from a command-line console. “java -jar selenium-server-standalone-<version-number>.jar” This can be simplified by creating a batch or shell executable file (.bat on Windows and .sh on Linux) containing the command above. Then make a shortcut to that executable on our desktop and simply double-click the icon to start the server. 5

6 A test program can be run on selenium RC and Web driver.
Running a test A test program can be run on selenium RC and Web driver. Selenium RC requires a selenium RC server and language specific client driver, whereas Web driver requires only server. Selenium has a set of libraries available in the specific programming language. 6

7 Running a test in selenium RC
Install the Selenium RC Server. Set up a programming project using a language specific client driver. Create the test program in a suitable environment. Before starting any tests we must start the server . Once the server has started, we can run the test program by giving Run as--> Java application or Junit test case. For Web driver, we can run the program directly. Its not necessary to start the server separately. 7 7

8 SELENIUM GRID Selenium Grid allows us to :
Scale by distributing tests on several machines ( parallel execution ). Manage multiple environments from a central point. Making it easy to run the tests against a vast combination of browsers / OS. Minimize the maintenance time for the grid by allowing us to implement custom hooks to leverage virtual infrastructure for instance. 8

9 Selenium Grid uses a hub-node concept where you only run the test on a single machine called a hub, but the execution will be done by different machines called nodes. 9

10 WHEN TO USE SELENIUM GRID?
Run your tests against different browsers, operating systems, and machines all at the same time. This will ensure that the application you are testing is fully compatible with a wide range of browser-OS combinations. Save time in execution of your test suites. If you set up Selenium Grid to run, say, 4 tests at a time, then you would be able to finish the whole suite around 4 times faster. 10

11 GRID VERSIONS There are two versions of Selenium Grid. They are
(i)Grid 1.0 (ii)Grid 2.0 GRID 1.0: Selenium Grid 1 has its own remote control that is different from the Selenium RC server. We need to install and configure Apache Ant first before you can use Grid and it can only support Selenium RC commands/scripts. We can automate only one browser per remote control. GRID 2.0: Selenium Grid 2 is now bundled with the Selenium Server jar file. We do not need to install Apache Ant in Grid 2 and can support Selenium RC and Web Driver Scripts. We can automate up to 5 browsers. 11

12 HUB AND NODE The hub is the central point where we load our tests into. There should only be one hub in a grid. The hub is launched only on a single machine, say, a computer whose OS is Windows 7 and whose browser is IE. The machine containing the hub is where the tests will be run, but you will see the browser being automated on the node. NODE: Nodes are the Selenium instances that will execute the tests that you loaded on the hub. There can be one or more nodes in a grid. Nodes can be launched on multiple machines with different platforms and browsers. The machines running the nodes need not be the same platform as that of the hub. HUB: 12

13 Selenium grid requirements
Two machines. One to act as hub(Machine A). One to act as node(Machine B) . Selenium server .jar file. 13

14 Setting up selenium Grid
Download selenium server .jar file. Place the jar file in the hard drive of both machine A and machine B. 14

15 Configuration of hub and node
Open the hub (machine A) Open command prompt and traverse to the directory which has the server .jar file. Type “java -jar selenium-server-standalone jar -role hub”. Do the same in node (machine B ) using the command “java -jar selenium-server-standalone jar -role node -hub Now the hub and node configuration is completed. 15

16 Adding additional nodes
Any number of nodes can be added. All the additional nodes should have .jar file in their hard drive. Open command prompt in all machines. Traverse to directory which contains the .jar file in each machine. Type “java -jar selenium-server-standalone jar -role node -hub Where is the IP address of the hub. 16

17 Designing Test Scripts That Can Run on the Grid
To design test scripts that will run on the grid, we need to use DesiredCapabilites and the RemoteWebDriver objects. DesiredCapabilites is used to set the type of browser and OS that we will automate. RemoteWebDriver is used to set which node (or machine) that our test will run against. 17

18 Using the DesiredCapabilites Object
Go to the Grid's web interface and hover on an image of the browser that you want to automate. Take note of the platform and the browserName shown by the tool tip. Also, to use the DesiredCapabilites object, you must first import this package in the program. In this case, the platform is "XP" and the browserName is "firefox". 18

19 Using the RemoteWebDriver Object
To use the RemoteWebDriver object, you must import these packages. Then pass the DesiredCapabilities object that we created before as a parameter for the RemoteWebDriver object. 19

20 Running a Sample Test Case on the Grid
Below is a simple WebDriver TestNG code that you can create in Eclipse on Machine A(Hub). Once you run it, automation will be performed on Machine B(Node). 20

21 There are two main ways to go about expanding your selenium testing
Selenium Grid Considerations There are two main ways to go about expanding your selenium testing to include multiple browsers and multiple versions DIY with Selenium Grid or using a cloud solution like Sauce Labs, which is effectively Selenium Grid in the cloud without the infrastructure setup or maintenance. The high maintenance nature of building a Grid results in a high TCO but there is a return on that investment. Building a Selenium Grid has two key benefits Control Speed of test execution Selenium Grid is a solution enabling web-testing on a larger scale and continuous integration 21

22 THANK YOU 22


Download ppt "Selenium server By, Kartikeya Rastogi Mayur Sapre Mosheca. R"

Similar presentations


Ads by Google