Русские видео

Сейчас в тренде

Иностранные видео


Скачать с ютуб Page Object Model Framework in selenium Step by Step - Java By Kiran. в хорошем качестве

Page Object Model Framework in selenium Step by Step - Java By Kiran. 3 года назад


Если кнопки скачивания не загрузились НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием, пожалуйста напишите в поддержку по адресу внизу страницы.
Спасибо за использование сервиса savevideohd.ru



Page Object Model Framework in selenium Step by Step - Java By Kiran.

Advantages of POM This is a very important framework in selenium and many companies use this framework. Some of the advantages of Page Object Model are as follows: Every page in the product can have one class for selenium operation in Agile, as and when pages are created by developer, at the same time QA can start working on writing test cases for that page. Page Object Pattern says, operations and flows in the UI should be separated from verification. This concept makes our code cleaner and easy to understand. The Second benefit is that the object repository is independent of test cases, so we can use the same object repository for different purposes with different tools. For example, we can integrate POM with TestNG/JUnit for functional Testing and at the same time with JBehave/Cucumber for acceptance testing. The code becomes less lengthy and optimized because of the reusable page methods in the POM classes. Methods should be named more realistic names which can be easily mapped with the operation happening in the UI. For eg: If after clicking on the button we are redirected on the home page, then the method name will be like ‘navigateToHomePage()’. Simple and clear page classes with sensible method names. One can actually give the customized names to ones methods as mentioned above, so that one need not have to remember much. Just looking into the method name gives all ideas about the capabilities of the method. Makes tests more readable in comparison to the above commands of selenium, wherein one need to add all the commands in the test scripts. In page object model one needs to put method names. The methods which one has created according to one’s understanding of application then these method’s names become more readable and easy to understand. Stay DRY as page object model believes in the principle of Do not repeat yourself i.e. DRY. Better support of tests because everything is stored in one place. Easy creation of new tests. In fact, tests can be created by a person who is unaware of the features of automation tools. Disadvantages of POM All locators should be kept in page class file. And this abstraction leads to some chaos within the Page Class file. So you need to implement something like a key word driven on top of Page Object Model so as to fully take the advantages. Requires quite good programming skills to design the automation suite (+ or – depending on the programming skills of the team). POM Building Steps Creating a Page Object Model in Java Here, we’ll create an automation framework and implement a Page Object Model using Selenium with Java. Suppose we have to test a dummy application with only a login page and a home page, then after clicking on it user page will be displayed. To start with we first need to create page objects for all available pages in our application such as ‘LoginPage.java’, ‘HomePage.java’ and ‘Userspage.java’. Then we will create a test class that will create instances of these page objects and invokes their methods to create a test. Let’s take the scenario wherein the ‘login page’ user enters valid credentials and on clicking the ‘submit’ button, the user is redirected to the ‘home page’. The ‘Page Object’ model works best when used in the right situation. It follows the lazy initialization design. So the WebDriver doesn’t load the elements until they come into the picture. This model is a by-product of the Factory Design Pattern. It is recommended to create a separate Factory Object to initialize the other objects. This method leaves behind all other frameworks in terms of both maintenance and performance. Create a class called ‘LoginPage.java’ as shown below. Here we will be trying to show all features in the code. Remember, whenever we write code here, we must cover the below points: Fetch all web elements of the web page. Elements like textboxes of username and password, labels of username and password, and even we can locate all error messages that appear on the page. We also need to locate the sign-in button. All operations. Operations such as entering test into all textboxes, clicking a button and all other which we come across. Navigations from one page to other pages. Navigation can be done after clicking on any button by which we can go to ‘home page’. When we click on the back button on the home page, we will reach to the login page. All verifications. Verifications need to be done so that in the later stage, we can call those methods through testNG.

Comments