0
0
Selenium Javatesting~10 mins

Test class consuming page objects in Selenium Java - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare the WebDriver variable in the test class.

Selenium Java
private WebDriver [1];
Drag options to blanks, or click blank then click option'
Adriver
Bbrowser
CwebDriver
DpageDriver
Attempts:
3 left
💡 Hint
Common Mistakes
Using uncommon or unclear variable names like 'pageDriver' which can confuse readers.
2fill in blank
medium

Complete the code to initialize the page object in the test setup method.

Selenium Java
loginPage = new LoginPage([1]);
Drag options to blanks, or click blank then click option'
Anull
BpageDriver
Cdriver
Dthis
Attempts:
3 left
💡 Hint
Common Mistakes
Passing null or unrelated variables instead of the WebDriver instance.
3fill in blank
hard

Fix the error in the test method to call the login method from the page object.

Selenium Java
loginPage.[1]("user", "pass");
Drag options to blanks, or click blank then click option'
Alogin
BsignIn
Csubmit
Dauthenticate
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names that do not exist in the page object like 'signIn' or 'authenticate'.
4fill in blank
hard

Fill both blanks to assert the page title after login.

Selenium Java
assertEquals([1], driver.[2]());
Drag options to blanks, or click blank then click option'
A"Dashboard"
BgetTitle
CgetCurrentUrl
D"Login Page"
Attempts:
3 left
💡 Hint
Common Mistakes
Using getCurrentUrl() instead of getTitle() to check the page title.
5fill in blank
hard

Fill all three blanks to properly close the browser after tests.

Selenium Java
if (driver != null) {
    driver.[1]();
    driver = [2];
    loginPage = [3];
}
Drag options to blanks, or click blank then click option'
Aquit
Bnull
Dclose
Attempts:
3 left
💡 Hint
Common Mistakes
Using driver.close() which only closes one window, not the entire browser session.
Not setting variables to null after quitting.