0
0
Selenium Javatesting~10 mins

Submitting forms 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 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'
Asubmit
Bclear
CsendKeys
Dclick
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
2fill in blank
medium

Complete 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'
Aname
BtagName
CclassName
Did
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
3fill in blank
hard

Fix 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'
Aclick
BsendKeys
Csubmit
Dclear
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() on the form element which does not submit it
Using sendKeys() or clear() which are unrelated
4fill in blank
hard

Fill 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'
Aname
Bid
CloginForm
DsubmitForm
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.id when the form has a name attribute
Using the wrong form name string
5fill in blank
hard

Fill 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'
AclassName
Bsubmit-button
Cclick
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.id when the button is identified by class
Using submit() on the button instead of click()