- Selenium Tutorial
- Selenium - Home
- Selenium - Overview
- Selenium - Components
- Selenium - Automation Testing
- Selenium - Environment Setup
- Selenium - Remote Control
- Selenium IDE Tutorial
- Selenium - IDE Introduction
- Selenium - Features
- Selenium - Limitations
- Selenium - Installation
- Selenium - Creating Tests
- Selenium - Creating Script
- Selenium - Store Variables
- Selenium - Alerts & Popups
- Selenium - Selenese Commands
- Selenium - Actions Commands
- Selenium - Accessors Commands
- Selenium - Assertions Commands
- Selenium - Assert/Verify Methods
- Selenium - Locating Strategies
- Selenium - Script Debugging
- Selenium - Verification Points
- Selenium - Pattern Matching
- Selenium - JSON Data File
- Selenium - Browser Execution
- Selenium - User Extensions
- Selenium - Code Export
- Selenium - JavaScript Functions
- Selenium - Plugins
- Selenium WebDriver Tutorial
- Selenium - Introduction
- Selenium WebDriver vs RC
- Selenium - Installation
- Selenium - First Test Script
- Selenium - Driver Sessions
- Selenium - Browser Options
- Selenium - Chrome Options
- Selenium - Edge Options
- Selenium - Firefox Options
- Selenium - Safari Options
- Selenium Web Elements
- Selenium - File Upload
- Selenium - Locator Strategies
- Selenium - Relative Locators
- Selenium - Finders
- Selenium - Find All Links
- Selenium - User Interactions
- Selenium - WebElement Commands
- Selenium - Browser Interactions
- Selenium - Browser Commands
- Selenium - Browser Navigation
- Selenium - Alerts & Popups
- Selenium - Handling Forms
- Selenium - Windows and Tabs
- Selenium - Handling Links
- Selenium - Input Boxes
- Selenium - Radio Button
- Selenium - Checkboxes
- Selenium - Dropdown Box
- Selenium - Handling IFrames
- Selenium - Handling Cookies
- Selenium - Date Time Picker
- Selenium - Dynamic Web Tables
- Selenium - Actions Class
- Selenium - Keyboard Events
- Selenium - Key Up/Down
- Selenium - Copy and Paste
- Selenium - Handle Special Keys
- Selenium - Mouse Events
- Selenium - Drag and Drop
- Selenium - Scroll Operations
- Selenium - Waiting Strategies
- Selenium - Explicit/Implicit Wait
- Selenium - Support Features
- Selenium - Multi Select
- Selenium - Wait Support
- Selenium - Color Support
- Selenium - Errors & Logging
- Selenium - Logging
- Selenium - Exception Handling
- Selenium - Miscellaneous
- Selenium - Handling Ajax Calls
- Selenium - JSON Data File
- Selenium - CSV Data File
- Selenium - Excel Data File
- Selenium - Cross Browser Testing
- Selenium - Multi Browser Testing
- Selenium - Multi Windows Testing
- Selenium - JavaScript Executor
- Selenium - Headless Execution
- Selenium - Capture Screenshots
- Selenium - Capture Videos
- Selenium - Page Object Model
- Selenium - Page Factory
- Selenium - Record & Playback
- Selenium - Frameworks
- Selenium - Browsing Context
- Selenium Grid Tutorial
- Selenium - Overview
- Selenium - Architecture
- Selenium - Components
- Selenium - Configuration
- Selenium - Create Test Script
- Selenium - Test Execution
- Selenium - Endpoints
- Selenium - Customizing a Node
- Selenium Reporting Tools
- Selenium - Reporting Tools
- Selenium - TestNG
- Selenium - JUnit
- Selenium - Allure
- Selenium & other Technologies
- Selenium - Java Tutorial
- Selenium - Python Tutorial
- Selenium - C# Tutorial
- Selenium - Javascript Tutorial
- Selenium - Kotlin Tutorial
- Selenium - Ruby Tutorial
- Selenium - Maven & Jenkins
- Selenium - Database Testing
- Selenium - LogExpert Logging
- Selenium - Log4j Logging
- Selenium - Robot Framework
- Selenium - AutoIT
- Selenium - Flash Testing
- Selenium - Apache Ant
- Selenium - Github
- Selenium - SoapUI
- Selenium - Cucumber
- Selenium - IntelliJ
- Selenium - XPath
- Selenium Miscellaneous Concepts
- Selenium - Automation Frameworks
- Selenium - Keyword Driven Framework
- Selenium - Data Driven Framework
- Selenium - Hybrid Driven Framework
- Selenium - SSL Certificate Error
- Selenium - Alternatives
- Selenium Useful Resources
- Selenium - Quick Guide
- Selenium - Useful Resources
- Selenium - Automation Practice
- Selenium - Discussion
Selenium IDE - Assert/Verify Methods
Selenium IDE uses assert and verify methods to check if a certain text, element, page title, and so on matches with the requirements. These two methods basically help us to conclude if a test has passed or failed based on the verification points added(in the form of assert and verify commands)
What is an Assert Command?
In Selenium IDE, an assert command is used to verify if a certain situation is matching with the specification document. In case, they are not matching, the test execution stops at the point of a mismatch.
What is a Verify Command?
In Selenium IDE, a verify command is also used to verify if a certain situation is matching with the specification document. In case, they are not matching, the test execution does not stop at the point of a mismatch. The error is captured at the Log in Selenium IDE and the steps after the error IS encountered also get executed.
Example With Assert Command
Let us take an example of the below page, where we would capture the page title Selenium Practice - Radio Button and check if the correct page title is displayed using the assert command.
The steps to use an assert command are listed below −
Step 1 − Click on the Selenium IDE extension visible on the browser after its installation.
Step 2 − Selenium IDE should be launched along with it, a welcome message should be displayed with the version of the tool. In the below image, the version installed is 3.17.2.
Along with this, it gives us the option to select what we would like to do with the tool, like Record a new test in a new project, Open an existing project, Create a new project, and Close Selenium IDE.
Also, a link with the text - the Selenium IDE project page is provided, which on clicking would land us to the Selenium Integrated Development Environment documentation page.
https://www.selenium.dev/selenium-ide/.
Step 3 − Click on the Create a new project link, then enter a project name, say, Test6 under the Please provide a name for your new project. Finally, we would click on the OK button.
Step 4 − We would have the workspace ready in the Selenium IDE now.
Step 5 − Enter open in the Command field, and https://www.tutorialspoint.com/selenium/ in the Target field, to launch the application.
Step 6 − Enter store title in the Command field, and pageTitle in the Value field. Please note, pageTitle is variable to capture the title of the application launched.
Step 7 − Enter assert title in the Command field, ABC in the Target field. Please note, in this step we are verifying if the page tile is ABC.
Step 8 − Enter echo in the Command field, ${pageTitle} in the Target field. Please note, this would print the text we obtained in Step6 under the Log in Selenium IDE.
Step 9 − Enter close in the Command field to close the browser window.
Step 10 − Click on the three dots appearing at the left pane, then select the Rename option.
Step 11 − Enter a name, say Test6 under the Rename Test case field, then click on Rename. The entered name would appear on the left of Selenium IDE.
Step 12 − Click on the Run all tests from the top, and wait for the test execution to complete. In our example, we would see Runs: 1, Failures: 1, and a red bar denoting the test ran unsuccessfully with failures. Also, the message Test6 ended with 1 error(s) would appear under the Log.
In the example above, we had obtained the page title which is Selenium Practice - Radio Button. However, we had added the assert title command to check if the page title is equal to ABC. Hence the actual and the expected values did not match. Moreover, due to the assert command, the execution halted and the steps 4, and 5 did not execute.
Example With Verify Command
Let us take the same above example, where we would capture the page title Selenium Practice - Radio Button and check if the correct page title is displayed using the verify command.
The steps to capture the browser title are listed below −
Step 1 − Follow steps 1 to 6 from the previous example.
Step 2 − Enter verify title in the Command field, ABC in the Target field. Please note, in this step we are verifying if the page tile is ABC.
Step 3 − Follow steps 8,9, 10, 11, and 12 from the previous example.
In the example above, we had obtained the page title which is Selenium Practice - Radio Button. However, we had added the verify title command to check if the page title is equal to ABC. Hence the actual and the expected values did not match. Moreover, even after encountering failure in step3 the steps 4, and 5 executed and the execution did not stop in between, simultaneously, the error also got recorded under the Log.
What is the difference between assert and verify commands?
From the above examples, we can infer that both assert and verify commands can be used for verification purposes. But in case of errors encountered in a test, the execution stops at the failed step, and remaining steps do not get executed while assert command is used. However, the execution continued even after encountering a failed step, while we are using the verify command. The error encountered is also recorded under the Log in Selenium IDE for both the commands.
This concludes our comprehensive take on the tutorial on Selenium IDE - Assert/Verify methods. We’ve started with describing what is an assert and a verify command in Selenium IDE, and walked through examples having an assert command and a verify command, illustrated how to use them, and the basic differences between the two commands along with Selenium. This equips you with in-depth knowledge of the assert and verify methods in Selenium IDE. It is wise to keep practicing what you’ve learned and exploring others relevant to Selenium to deepen your understanding and expand your horizons.
To Continue Learning Please Login
Login with Google