0
0
Selenium Javatesting~10 mins

Why Selenium with Java is an industry standard in Selenium Java - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new ChromeDriver instance in Selenium with Java.

Selenium Java
WebDriver driver = new [1]();
Drag options to blanks, or click blank then click option'
AChromeDriver
BSafariDriver
CFirefoxDriver
DEdgeDriver
Attempts:
3 left
💡 Hint
Common Mistakes
Using FirefoxDriver when ChromeDriver is needed.
Forgetting to import the correct driver class.
2fill in blank
medium

Complete the code to open the URL 'https://example.com' using Selenium WebDriver.

Selenium Java
driver.[1]("https://example.com");
Drag options to blanks, or click blank then click option'
Aget
BgetTitle
Cnavigate
DfindElement
Attempts:
3 left
💡 Hint
Common Mistakes
Using getTitle() which returns the page title.
Using findElement() which locates elements.
3fill in blank
hard

Fix the error in the code to click a button with id 'submitBtn'.

Selenium Java
driver.findElement(By.id([1])).click();
Drag options to blanks, or click blank then click option'
AsubmitBtn"
B"submitBtn"
C'submitBtn'
DsubmitBtn
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the id string.
Using single quotes which are invalid in Java for strings.
4fill in blank
hard

Fill both blanks to wait up to 10 seconds for an element with id 'username' to be visible.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds([1]));
wait.until(ExpectedConditions.[2](By.id("username")));
Drag options to blanks, or click blank then click option'
A10
B5
CvisibilityOfElementLocated
DelementToBeClickable
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong wait time.
Using elementToBeClickable instead of visibilityOfElementLocated.
5fill in blank
hard

Fill all three blanks to create a test that opens Google, searches for 'Selenium', and submits the search.

Selenium Java
driver.get("https://www.google.com");
WebElement searchBox = driver.findElement(By.[1]("q"));
searchBox.sendKeys([2]);
searchBox.[3]();
Drag options to blanks, or click blank then click option'
Aname
B"Selenium"
Csubmit
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using id instead of name for locator.
Not putting search text in quotes.
Using click() instead of submit().