Bird
0
0

What will be the output of this Selenium Java code if the form submission disables the submit button with id 'submitBtn'?

medium📝 Predict Output Q5 of 15
Selenium Java - Handling Form Elements
What will be the output of this Selenium Java code if the form submission disables the submit button with id 'submitBtn'? WebElement submit = driver.findElement(By.id("submitBtn")); boolean enabledBefore = submit.isEnabled(); submit.click(); boolean enabledAfter = submit.isEnabled(); System.out.println(enabledBefore + "," + enabledAfter);
Atrue,true
Bfalse,true
Ctrue,false
Dfalse,false
Step-by-Step Solution
Solution:
  1. Step 1: Check button state before click

    Initially, the submit button is enabled, so isEnabled() returns true.
  2. Step 2: Check button state after click disables it

    After clicking, the button becomes disabled, so isEnabled() returns false.
  3. Final Answer:

    Prints true,false -> Option C
  4. Quick Check:

    Button enabled before click, disabled after = true,false [OK]
Quick Trick: Check isEnabled() before and after click to verify button state changes [OK]
Common Mistakes:
  • Assuming button stays enabled after click
  • Mixing up true and false values
  • Not considering UI changes after submission

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes