State the major difference between “assert” and “verify” commands in Selenium.
Both “assert” and “verify” commands check whether the given condition is true or false and the only difference between them is that:
Assert: Assert condition stops the execution of the testing if the given condition is false else would continue with the further tests.
Verify: Verify the condition doesn’t stop the flow of execution irrespective of the condition being true or false.
2 What do you understand about the Page Object Model in the context of Selenium? What are its advantages?
Page Object Model (POM) is a design pattern that generates an Object Repository for web UI elements and is widely used in test automation. The paradigm has the advantage of reducing code duplication and improving test maintenance. According to this paradigm, each web page in the application should have its own Page Class. This Page class will identify the web pages WebElements and also has Page methods that operate on those WebElements. The names of these methods should correspond to the tasks they perform, for example, if a loader is waiting for the payment gateway to appear, the POM method name could be waitForPaymentScreenDisplay().
Following are the advantages of the Page Object Model (POM) :
According to the Page Object Design Pattern, user interface activities and flows should be separated from verification. Our code is clearer and easier to understand as a result of this notion.
The second advantage is that the object repository is independent of test cases, allowing us to reuse the same object repository with different tools. For example, we can use Selenium to combine Page Object Model with TestNG/JUnit for functional testing and JBehave/Cucumber for acceptability testing.
Because of the reusable page methods in the POM classes, code gets less and more efficient.
Methods are given more realistic names that can be easily associated with the UI operation. If we land on the home page after clicking the button, the function name will be gotoHomePage().
Previous Companies:
ACS Xerox Company
Iberostar Hotel
St James Preparatory School
1 Explain the various navigation commands supported by Selenium?
Selenium has the support of majorly 4 navigation commands:
navigate().back(): This command is used for taking the user to the last webpage of the browser history.
navigate().forward(): This command is used for taking the user to the next web page of the browser history.
navigate().refresh(): This command is used for reloading the web components of a webpage by refreshing it.
navigate().to(): This command is used for navigating to a particular URL in a new web browser. It takes the URL to be migrated to, as a parameter.
2 Explain different types of framework and connection of Selenium with Robot Framework.
Following are the different types of frameworks:
Behavior-Driven Development Framework: This type of framework provides a readable and easily understandable format to Business Analysts, Developers, Testers, etc.
Data-Driven Testing Framework: This type of framework helps separate test data from the test-script logic by storing test data in some external database in the form of key-value pairs. These keys can be used for accessing as well as populating data into the test scripts.
Keyword-Driven Testing Framework: This type of framework is an extension of the data-driven testing framework. In addition to separating test data and the test-script logic, it also separates a part of the test script code by storing it in an external data file.
Library Architecture Testing Framework: This type of framework groups common steps into functions under a library and calls these functions as and when required.
Module-Based Testing Framework: This type of framework divides each test application into several isolated and logical modules, with each module having its distinct test script.
Hybrid Testing Framework: This type of framework is a combination of the above-mentioned frameworks leveraging all their good features.
Robot Framework is a modular open-source automation framework that can interact with 3rd party libraries and functions. To execute a web testing library such as Selenium, a test automation runner or an automation wrapper is required, which is provided to it in the form of Robot Framework. Other popular test runners to serve the same purpose are MSTest, TestNG, Nunit, Junit, etc.
The below diagram shows the connection of the Robot framework to the Selenium library: