Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to type text into the input field.
Selenium Java
WebElement input = driver.findElement(By.id("username")); input.[1]("testuser");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using click instead of sendKeys
Using getText which only retrieves text
Using clear which removes text instead of typing
✗ Incorrect
The sendKeys method types the given text into the input field.
2fill in blank
mediumComplete the code to find the password input and type the password.
Selenium Java
WebElement passwordInput = driver.findElement(By.name("[1]")); passwordInput.sendKeys("mypassword");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user' or 'email' which are for other fields
Using 'submit' which is usually a button
✗ Incorrect
The password input field is usually identified by the name "password".
3fill in blank
hardFix the error in the code to type text into the search box.
Selenium Java
WebElement searchBox = driver.findElement(By.cssSelector("input.search")); searchBox.[1]("Selenium testing");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sendkey without capital K
Using made-up methods like typeKeys or inputText
✗ Incorrect
The correct method name is sendKeys with capital K and S.
4fill in blank
hardFill both blanks to clear the input field and then type new text.
Selenium Java
WebElement inputField = driver.findElement(By.id("searchBox")); inputField.[1](); inputField.[2]("new query");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Typing without clearing old text
Using click or getText instead of clear or sendKeys
✗ Incorrect
First clear the input field, then type new text using sendKeys.
5fill in blank
hardFill all three blanks to find the input by XPath, clear it, and type the text.
Selenium Java
WebElement input = driver.findElement(By.xpath("[1]")); input.[2](); input.[3]("hello world");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong XPath expression
Forgetting to clear before typing
Using incorrect method names
✗ Incorrect
Find the input by XPath with name 'search', clear it, then type with sendKeys.