A. The button element is inside an iframe and not switched to
B. The XPath is missing the button's id attribute
C. XPath is case-sensitive and 'Submit' text does not match
D. The button is disabled and cannot be clicked
Solution
Step 1: Check XPath correctness
The XPath //button[text()='Submit'] matches the button text exactly, which is correct here.
Step 2: Consider common Selenium issues
If the element is inside an iframe, Selenium cannot find it unless switched to that iframe first. This causes NoSuchElementException.
Final Answer:
The button element is inside an iframe and not switched to -> Option A
Quick Check:
NoSuchElementException often means iframe switch missing [OK]
Hint: Check if element is inside iframe before findElement [OK]
Common Mistakes:
Assuming XPath text match is case-insensitive
Ignoring iframe context
Thinking disabled buttons cause NoSuchElementException
5. You want to find an input field that has either name='email' or placeholder='Email'. Which XPath expression should you use with findElement?
hard
A. //input[@name='email' | @placeholder='Email']
B. //input[@name='email' or @placeholder='Email']
C. //input[contains(@name, 'email') or contains(@placeholder, 'Email')]
D. //input[@name='email' and @placeholder='Email']
Solution
Step 1: Understand the requirement
You want to find an input element that matches either condition: name='email' OR placeholder='Email'.
Step 2: Analyze XPath options
//input[@name='email' or @placeholder='Email'] uses the correct XPath OR operator or between attribute checks. //input[@name='email' and @placeholder='Email'] uses and which requires both attributes. //input[contains(@name, 'email') or contains(@placeholder, 'Email')] uses contains which is broader but acceptable, but the question asks exact match. //input[@name='email' | @placeholder='Email'] uses invalid XPath syntax with | inside predicate.
Final Answer:
//input[@name='email' or @placeholder='Email'] -> Option B
Quick Check:
Use 'or' inside XPath predicate for either condition [OK]
Hint: Use 'or' inside XPath brackets for multiple attribute options [OK]
Common Mistakes:
Using 'and' instead of 'or' for either condition
Using invalid XPath operators like '|' inside predicates
Confusing contains() with exact match
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.