Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the WebDriver in a hybrid framework.
Selenium Java
WebDriver driver = new [1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using FirefoxOptions instead of FirefoxDriver
Confusing WebElement with WebDriver
Trying to instantiate Actions directly as WebDriver
✗ Incorrect
In Selenium with Java, to start a browser session, you create an instance of a WebDriver implementation like ChromeDriver.
2fill in blank
mediumComplete the code to read test data from an Excel file in the hybrid framework.
Selenium Java
FileInputStream file = new FileInputStream("data.xlsx"); Workbook workbook = new [1](file);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using FileReader which is for text files
Using BufferedReader which reads text streams
Using Sheet which represents a sheet, not the workbook
✗ Incorrect
XSSFWorkbook is used to read .xlsx Excel files in Apache POI library.
3fill in blank
hardFix the error in the assertion statement to verify the page title.
Selenium Java
Assert.[1](driver.getTitle(), "Expected Title");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertTrue with two arguments causes compilation error
Using assertNull or assertNotNull is incorrect for title comparison
✗ Incorrect
assertEquals compares two values for equality, which is correct for verifying page title.
4fill in blank
hardFill both blanks to create a reusable method that clicks a button by locator in the hybrid framework.
Selenium Java
public void clickButton(By [1]) { driver.[2]([1]).click(); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' as parameter name
Using driver.click() which does not exist
Using 'By' as parameter name instead of a variable
✗ Incorrect
The method parameter is named locator of type By, and driver.findElement(locator) finds the element to click.
5fill in blank
hardFill all three blanks to create a data-driven test method that reads username and password from Excel and logs in.
Selenium Java
String username = sheet.getRow([1]).getCell([2]).getStringCellValue(); String password = sheet.getRow([1]).getCell([3]).getStringCellValue();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using row 0 which is header row
Mixing up cell indexes for username and password
✗ Incorrect
Row 1 is usually the first data row (after header), cell 0 for username, cell 2 for password assuming columns: 0=username, 1=ignored, 2=password.