Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to click the login button using the correct method.
Selenium Java
public void clickLogin() {
loginButton.[1]();
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sendKeys() to click a button instead of click()
Using clear() which is for input fields, not buttons
✗ Incorrect
The click() method is used to simulate a mouse click on a web element like a button.
2fill in blank
mediumComplete the code to enter text into the username field.
Selenium Java
public void enterUsername(String user) {
usernameField.[1](user);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of sendKeys() to enter text
Using getText() which only reads text, not types
✗ Incorrect
The sendKeys() method types the given text into an input field.
3fill in blank
hardFix the error in the method to clear the search box before typing.
Selenium Java
public void search(String query) {
searchBox.[1]();
searchBox.sendKeys(query);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() which only focuses the element
Using getText() which reads text but does not clear
✗ Incorrect
The clear() method empties the text in an input field before typing new text.
4fill in blank
hardFill both blanks to define a method that submits a form after entering email.
Selenium Java
public void submitEmail(String email) {
emailField.[1](email);
form.[2]();
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() on the form instead of submit()
Using clear() instead of sendKeys() to enter email
✗ Incorrect
First, sendKeys() types the email. Then, submit() sends the form.
5fill in blank
hardFill all three blanks to create a method that clears, types, and clicks the search button.
Selenium Java
public void performSearch(String term) {
searchInput.[1]();
searchInput.[2](term);
searchButton.[3]();
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using submit() instead of click() on the button
Not clearing the input before typing
✗ Incorrect
The method first clears the input, then types the term, and finally clicks the search button.