Download presentation
Presentation is loading. Please wait.
Published byAmy Curtis Modified over 8 years ago
1
SELENIUM By- Vivek Singh Jeena, Inderpreet Singh, Ankusha Saxena, Bhanupriya D.P, Shubham Yadav, Madhavi Aminigadda
2
Selenium is a robust set of tools that supports rapid development of test automation for web based applications. It is possibly the most widely used open source solution for assisting with the development of test automation. It provides a rich test of testing functions specifically geared to the needs of testing of a web application. SELENIUM
3
It provides the support for executing one's tests on multiple browser platforms. It is composed of four major tools : Selenium IDE Selenium RC(Remote Control) Selenium Web Driver Selenium Grid
4
WHY AUTOMATION TESTING? Test automation means using a tool to run repeatable test against the target application whenever necessary. The advantages of automation testing are related to the repeatability of the tests and the speed at which the test can be executed. Automation testing supports : Frequent regression testing. Rapid feedback to developers during the development process.
5
WHY AUTOMATION TESTING? Virtually unlimited iterations of test case execution Customized reporting of application defects Support for Agile and eXtreme development methodologies Disciplined documentation of test cases Finding defects missed by manual testing
6
HISTORY Selenium first came to life in 2004, when Jason Huggins was testing an internal application at ThoughtWorks. He realized there were better uses of his time than manually stepping through the same tests with every change he made. He developed a Javascript library that could drive interactions with the page, allowing him to automatically rerun tests against multiple browsers.
7
HISTORY That library eventually became Selenium Core, which underlies all the functionality of Selenium Remote Control (RC) and Selenium IDE. Selenium RC was ground-breaking because no other product allowed you to control a browser from a language of your choice. In 2006 a plucky engineer at Google named Simon Stewart started work on a project he called WebDriver.
8
CONT. The WebDriver project began with the aim to solve the Selenium' pain-points. But, the most important story of that year was the merging of Selenium and WebDriver. The joining of the two tools provided a common set of features for all users.
9
Selenium IDE : Architecture Doesn’t required to start server before executing the test script. It is a GUI Plug-in. It only works in Mozilla browser. Core engine is Javascript based
10
Selenium RC : Architecture
11
Selenium Web driver : Architecture
12
Selenium in Action Selenium is a package of various test components which consists of the following three major tools. Each one has a specific role in aiding the development of test automation for a Web application. Selenium IDE – A Firefox extension to record test cases and suites. Selenium RC – Used to run tests on different browsers and systems. Selenium Grid – Runs multiple instances of Selenium RC at once.
13
Selenium in Action Selenium Web Driver : Web Driver is a web automation framework that allows you to execute your tests against different browsers, not just Firefox (unlike Selenium IDE).
14
Selenium : Web driver
15
Web Driver is a web automation framework that allows you to execute your tests against different browsers, not just Firefox (unlike Selenium IDE). WebDriver also enables you to use a programming language in creating your test scripts(not possible in Selenium IDE). You can now use conditional operations like if- then-else or switch-case You can also perform looping like do-while.
16
Selenium : Web driver Selenium WebDriver is the successor to Selenium RC. Selenium WebDriver accepts commands (sent in Selenese, or via a Client API) and sends them to a browser. This is implemented through a browser-specific browser driver, which sends commands to a browser, and retrieves results. Most browser drivers actually launch and access a browser application (such as Firefox or Internet Explorer); there is also an HtmlUnit browser driver, which simulates a browser using HtmlUnit.
17
SELENIUM IDE Introduction Developed independently by Shinya Kasatani and was merged in Selenium in 2006. A plugin in Mozilla Firefox. Works on all three major platforms – Windows, Mac and Linux. Selenium IDE can record user interactions with the web browser and play them back to test for errors. Selenium IDE enables us to test web applications with zero knowledge of any test scripting language.
18
Installing selenium Open http://www.seleniumhq.org/http://www.seleniumhq.org/
19
Click on Download Selenium Click on the current release version of the Selenium IDE
20
For security, a Firefox notification will pop up. Click on "Allow." Wait until Firefox completes the download and then click "Install Now."
21
Wait until installation is completed. In the pop-up window, click "Restart Now." After Firefox has restarted, launch Selenium IDE using either of two ways: By pressing Ctrl+Alt+S By clicking on the Firefox menu button > Web Developer> Selenium IDE
22
Selenium IDE basics Selenium IDE should launch as shown. Create a new test case by going to File -> New Test Case.
23
We are now going to record our test. To do this, hit the red record switch to the right. Type in Google.com into your Firefox address bar: On the Google.com homepage, search for any query. For this example, we used the query ‘automated testing. Once the results page opens, stop the test by clicking the red toggle switch.
24
Now that we’ve recorded the test, let’s play it back. This is what your ‘Table’ pane should look like now: Click on the ‘Play current test case’ button.
25
Selenium IDE
26
Selenium IDE : UI 1. Menu bar - The menu bar has options to add, open and save test scripts and test suites. It also has some general edit options and it is even possible to specify a preferred programming language. 2. Base URL - Allows test scripts to be run across different domains.
27
– Speed Control: Controls how fast your test script runs. – Run All: Run all test scripts in Selenium IDE. – Run: Run a single test script in Selenium IDE. 3. Tool bar - The buttons in the tool bar are used to control the test scripts. Each button is explained below (starting from the left):
28
– Pause/Resume: Pause a running test script. – Step: Step through the test script once it has been paused. – Apply Rollup Rules: This allows us to group a sequence of actions into a single action. – Record: The record button. It will be enabled when Selenium IDE is recording.
29
4. Test script pane - The test script commands are displayed in the test script pane. There is one tab which shows us the script in the three-column table format. The other tab shows us the script in a preferred language.
30
The Command, Target and value textfields are corresponding to the three-column table structure. It is possible to edit the values by clicking on a specific row. Those three fields are explained below:
31
– Command: This select box has a list of all the Selenium commands. It is possible to type into it to use the auto complete functionality or use it as a dropdown. Some reference information is shown in the reference pane at the bottom once a specific action is selected. – Action: The first parameter specified for a command in the Reference tab of the bottom pane always goes in the Target field. – Value: If a second parameter is specified by the Reference tab, it always goes in the Value field.
32
5. Test suite pane - Shows the test scripts in the current test- suite along with the results. Log/Reference pane
33
The bottom pane is used for four different functions divided in separate tabs, like: Log, Reference, UI-Element, and Rollup information. Each function is explained below: – Log: Error messages and information messages are shown while the test is running. – Reference: Displays the documentation of the command actually selected. – UI-Element: Displays the UI-element mappings actually in use. – Rollup: Shows rollup rules.
34
Recording a Test Open Selenium IDE and enter the Base URL. Click on Record Button
35
Open URL in Mozilla Firefox. Enter the details and login if required. Go to Selenium IDE and stop the recording. The commands will be present in the Test Script Pane. During recording, Selenium-IDE will automatically insert commands into your test case based on your actions. Typically, this will include: * clicking a link - click or clickAndWait commands * entering values - type command * selecting options from a drop-down listbox - select command * clicking checkboxes or radio buttons - click command
36
Opening and Saving a Test Case However, Selenium distinguishes between test cases and test suites. To save Selenium-IDE tests, we can either save the individual test cases, or save the test suite. When we open an existing test case or suite, Selenium- IDE displays its Selenium commands in the Test Case Pane.
37
Running Test Cases We can run a test case all at once, stop and start it, run it one line at a time, run a single command we are currently developing, and we can do a batch run of an entire test suite. Run a Test Case - Click the Run button to run the currently displayed test case. Run a Test Suite - Click the Run All button to run all the test cases in the currently loaded test suite.
38
Stop and Start - The Pause button can be used to stop the test case while it is running. The icon of this button then changes to indicate the Resume button. To continue click Resume. Stop in the Middle - We can set a breakpoint in the test case to cause it to stop on a particular command. This is useful for debugging our test case. To set a breakpoint, select a command, right-click, and from the context menu select Toggle Breakpoint.
39
Start from the Middle - You can tell the IDE to begin running from a specific command in the middle of the test case. This also is used for debugging. To set a startpoint, select a command, right-click, and from the context menu select Set/Clear Start Point. Run Any Single Command - Double-click any single command to run it by itself. This is useful when writing a single command. It lets you immediately test a command you are constructing, when you are not sure if it is correct. You can double-click it to see if it runs correctly. This is also available from the context menu.
40
Exporting Test Cases
41
Selenese Commands A selenese command refers to what Selenium has to do. Commands in selenium are of three types. Some example of Selenium IDE commands are - open - Opens an URL in the test frame. This accepts both relative and absolute URLs. verifyLocation - Verifies that we have navigated to a particular URL.
42
Selenese Commands type - The target is the CSS selector for the element. The value is the value you wish to enter in the input field. click - Clicks on a link, button, checkbox or radio button. clickAndWait - Clicks on a link, button, checkbox or radio button and waits for the page to load check - Checks a radio button or checkbox.
43
Selenese Commands verifyVisible - Returns true if the specified element is visible, false otherwise determines if the specified element is visible. An element can be rendered invisible by setting the CSS "visibility" property to "hidden", or the "display" property to "none", either for the element itself or one if its ancestors. This method will fail if the element is not present. verifyNotVisible - Returns true if the specified element is not visible, false otherwise. The element must be present in the HTML document but not visible.
44
Selenese Commands verifyElementPresent - Verifies that the specified element is somewhere on the page even if it is not visible. verifyElementNotPresent - Verifies that the element is not present any where in the HTML document.
45
Create Commands
46
Verifying Page Elements Verifying UI elements on a web page. Selenese allows multiple ways of checking for UI elements. It is important that you understand these different methods because these methods define what you are actually testing.
47
Assertion or Verification Choosing between “assert” and “verify” comes down to convenience and management of failures. Effectively an “assert” will fail the test and abort the current test case, whereas a “verify” will fail the test and continue to run the test case.
48
Assertion or Verification contd... The best use of this feature is to logically group your test commands, and start each group with an “assert” followed by one or more “verify” test commands. An example follows:
49
Assertion or Verification contd... The above example first “asserts” that the correct page is loaded by comparing the title. Only if this passes will the following command run and “verify” that the text is present in the expected location. The test case then “asserts” the first column in the second row of the first table contains the expected value and only if this passed will the remaining cells in that row be “verified”.
50
Assertion or Verification Commands VerifyTextPresent : The command verifyTextPresent is used to verify specific text exists somewhere on the page. VerifyElementPresent : Use this command when you must test for the presence of a specific UI element, rather than its content. VerifyText : Use verifyText when both the text and its UI element must be tested. verifyText must use a locator. verifyTitle/assertTitle : verifies an expected page title.
51
AssertAlert : it will verify text and take action on alert box but if alert text not matches then it will stop execution. AssertAlertNotPresent : this command will becomes pass successfully if there is not any alert on page of your software web application during its execution. AssertAlertPresent : this command will be executed without any error if there is any alert message present on web application page
52
Creating Test Suites A test suite, less commonly known as a validation suite, is a collection of test cases that are intended to be used to test a software program to show that it has some specified set of behaviours. To create a test suite in Selenium IDE: Open Selenium IDE Go to File>New Test Suite To add test cases: Go to File>Add test case
53
Creating Test Suites contd. Navigate to the location of your test case Click on Add Repeat steps 3-5 for more test cases The Test suite that contains GoogleSignUpForm and GoogleSignUpErrors:
54
Creating Test Suites contd.
55
Exporting a Test Case
56
Other features Importing test case(s). The Edit menu allows copy, paste, delete, undo, and select all operations for editing the commands in your test case. Actions menu allows users to record, play entire test suite, play current test case, play or pause, play fast or slow, set break point, and execute current test step. Options menu allows users to change options of IDE, export test case to multiple language format, and clear history.
57
Other features contd. Help menu allows users to view documentation, UI-Element documentation and navigate to Selenium websites. The toolbar contains buttons for controlling the execution of your test cases, including a step feature for debugging your test cases
58
SUMMARY In an era of highly interactive and responsive software processes where many organizations are using some form of Agile methodology, test automation is frequently becoming a requirement for software projects. Test automation means using a software tool to run repeatable tests against the application to be tested. Selenium is possibly the most widely-used open source solution tool available for assisting with the development of test automation.
59
SELENIUM Selenium is a robust set of tools that supports rapid development of test automation for web-based applications. Selenium provides a rich set of testing functions specifically geared to the needs of testing of a web application. Selenium operations are highly flexible, allowing many options for locating UI elements and comparing expected test results against actual application behavior.
60
Selenium Features: Supports Cross Browser Testing. The Selenium tests can be run on multiple browsers. Allows scripting in several languages like Java, C#, PHP and Python. Assertion statements provide an efficient way of comparing expected and actual results. Inbuilt reporting mechanism. Selenium Components: Selenium IDE Selenium Remote Control Selenium Web Driver Selenium Grid
61
Assert command in selenium: When an "assert" command fails then test execution will be aborted. Assert is best used when the check value has to pass for the test to be able to continue to run. Example: log in. Verify command in selenium: When a "verify" command fails then test will continue executing and logging the failure. Verify is best used to check non critical things. Example: presence of a headline element.
62
Thank You
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.