0
0
Selenium Javatesting~10 mins

Click actions 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 click on the button element.

Selenium Java
WebElement button = driver.findElement(By.id("submitBtn"));
button.[1]();
Drag options to blanks, or click blank then click option'
Aclick
Bclear
CgetText
DsendKeys
Attempts:
3 left
💡 Hint
Common Mistakes
Using sendKeys() instead of click() to click a button.
Trying to use getText() which only reads text, not clicks.
2fill in blank
medium

Complete the code to click on a link using its visible text.

Selenium Java
driver.findElement(By.linkText("[1]"))
      .click();
Drag options to blanks, or click blank then click option'
Ausername
BsubmitBtn
CHome
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using an element ID instead of link text in By.linkText().
Trying to click on input field names instead of link text.
3fill in blank
hard

Fix the error in the code to correctly click on a button using XPath.

Selenium Java
driver.findElement(By.xpath("//button[@id='[1]']"))
      .click();
Drag options to blanks, or click blank then click option'
AsubmitBtn")
BsubmitBtn
CsubmitBtn"
DsubmitBtn'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding extra quotes or parentheses inside the XPath string.
Mismatching single and double quotes causing syntax errors.
4fill in blank
hard

Fill both blanks to wait until the button is clickable, then click it.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.[1](ExpectedConditions.[2](By.id("submitBtn"))).click();
Drag options to blanks, or click blank then click option'
Auntil
BelementToBeClickable
CvisibilityOfElementLocated
DpresenceOfElementLocated
Attempts:
3 left
💡 Hint
Common Mistakes
Using visibilityOfElementLocated which waits for visibility but not clickability.
Using presenceOfElementLocated which waits only for presence in DOM.
5fill in blank
hard

Fill all three blanks to perform a click using Actions class on a button with id 'submitBtn'.

Selenium Java
Actions actions = new Actions(driver);
actions.[1](driver.findElement(By.[2]("[3]"))).perform();
Drag options to blanks, or click blank then click option'
Aclick
Bid
CsubmitBtn
DmoveToElement
Attempts:
3 left
💡 Hint
Common Mistakes
Using moveToElement() which moves the mouse to the element but does not click.
Using wrong locator type or element id.