Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to submit the form using Selenium WebDriver.
Selenium Java
WebElement form = driver.findElement(By.id("loginForm")); form.[1]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() on the form element instead of submit()
Using sendKeys() which is for input fields
Using clear() which clears text fields
✗ Incorrect
The submit() method submits the form element found by Selenium.
2fill in blank
mediumComplete the code to submit a form by clicking the submit button.
Selenium Java
WebElement submitButton = driver.findElement(By.[1]("submitBtn")); submitButton.click();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.name when the element has an id
Using By.className which may not be unique
Using By.tagName which is too generic
✗ Incorrect
Using By.id("submitBtn") locates the submit button by its id attribute.
3fill in blank
hardFix the error in the code to submit the form correctly.
Selenium Java
WebElement form = driver.findElement(By.id("form1")); form.[1]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() on the form element which does not submit it
Using sendKeys() or clear() which are unrelated
✗ Incorrect
The submit() method submits the form; click() on form element does not submit it.
4fill in blank
hardFill both blanks to locate the form by name and submit it.
Selenium Java
WebElement form = driver.findElement(By.[1]("[2]")); form.submit();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.id when the form has a name attribute
Using the wrong form name string
✗ Incorrect
Locate the form by its name attribute 'loginForm' using By.name().
5fill in blank
hardFill all three blanks to find the submit button by class, click it, and verify the form submission.
Selenium Java
WebElement submitBtn = driver.findElement(By.[1]("[2]")); submitBtn.[3]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.id when the button is identified by class
Using submit() on the button instead of click()
✗ Incorrect
Locate the button by className 'submit-button' and click it to submit the form.