Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to open a Chrome browser using Selenium WebDriver.
Selenium Java
WebDriver driver = new [1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using FirefoxDriver when ChromeDriver is needed.
Forgetting to instantiate the driver.
✗ Incorrect
The ChromeDriver class is used to launch the Chrome browser in Selenium.
2fill in blank
mediumComplete the code to navigate to the URL 'https://example.com'.
Selenium Java
driver.[1]("https://example.com");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'navigate' directly instead of 'get'.
Using non-existent methods like 'open' or 'visit'.
✗ Incorrect
The get method loads a new web page in the current browser window.
3fill in blank
hardFix the error in the code to find an element by its ID 'submitBtn'.
Selenium Java
WebElement button = driver.findElement(By.[1]("submitBtn"));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' or 'className' instead of 'id'.
Using 'tagName' which looks for HTML tags.
✗ Incorrect
The By.id locator finds elements by their ID attribute.
4fill in blank
hardFill both blanks to click a button with ID 'loginBtn' and then close the browser.
Selenium Java
driver.findElement(By.[1]("loginBtn")).[2]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'submit' instead of 'click' to press the button.
Using 'close' on the element instead of the driver.
✗ Incorrect
First, find the element by id, then perform a click action on it.
5fill in blank
hardFill the blanks to assert the page title is 'Welcome Page' using JUnit.
Selenium Java
String title = driver.getTitle(); [1]("[2]", title);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertTrue or assertFalse instead of assertEquals.
Mixing up expected and actual values.
✗ Incorrect
Use assertEquals to compare the expected title 'Welcome Page' with the actual title.