From the course: Test Automation with Selenium WebDriver for Java
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Using Page Objects in tests
From the course: Test Automation with Selenium WebDriver for Java
Using Page Objects in tests
- [Instructor] Every web test needs to open and close the browser and use Selenium web driver to interact with the page. Rather than duplicating this code in every test method, you can extract it out and place it into methods that run before and after your test suite. For that, we'll use a base test class that every other test class can inherit from. This class lives under the source test Java directory. Let's start by declaring a web driver instance that can be used across all tests, and we'll make this protected so that it's accessible in all test classes that inherit from this one. So we can say protected static WebDriver driver. Next, we'll create a setup method and we can say public static void, and we'll call this setup. In this method, we can set up our chrome driver executable. So let's say chromedriver.setup. And we can also specify any preferred options. So let's say chrome options, we'll call this options, equals new chrome options. To run selenium tests in GitHub code…
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Framework and tests1m 12s
-
(Locked)
Page Object Model design pattern1m 16s
-
(Locked)
Initializing elements3m 1s
-
(Locked)
Implementing interaction methods5m 3s
-
(Locked)
Using Page Objects in tests7m 45s
-
(Locked)
Code challenge: Implement Page Object Model47s
-
(Locked)
Solution: Implement Page Object Model4m 5s
-
(Locked)
-