0
0
Selenium Javatesting~10 mins

Select by value, visible text, index in Selenium Java - Interactive Code Practice

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

Complete the code to select an option by its visible text.

Selenium Java
Select dropdown = new Select(driver.findElement(By.id("menu")));
dropdown.selectBy[1]("Option 1");
Drag options to blanks, or click blank then click option'
AselectByIndex
BselectByValue
CselectByVisibleText
DselectByName
Attempts:
3 left
💡 Hint
Common Mistakes
Using selectByValue when you want to select by the text shown.
Using selectByIndex without knowing the option position.
2fill in blank
medium

Complete the code to select an option by its value attribute.

Selenium Java
Select dropdown = new Select(driver.findElement(By.name("choices")));
dropdown.[1]("val2");
Drag options to blanks, or click blank then click option'
AselectByValue
BselectByIndex
CselectById
DselectByVisibleText
Attempts:
3 left
💡 Hint
Common Mistakes
Using selectByVisibleText when the value attribute is needed.
Using selectByIndex without knowing the option's position.
3fill in blank
hard

Fix the error in the code to select an option by its index.

Selenium Java
Select dropdown = new Select(driver.findElement(By.cssSelector("#list")));
dropdown.selectBy[1](2);
Drag options to blanks, or click blank then click option'
AselectByPosition
BselectByVisibleText
CselectByValue
DselectByIndex
Attempts:
3 left
💡 Hint
Common Mistakes
Using selectByValue or selectByVisibleText with an integer argument.
Using a non-existent method like selectByPosition.
4fill in blank
hard

Fill both blanks to select an option by visible text and then by index.

Selenium Java
Select dropdown = new Select(driver.findElement(By.id("dropdown")));
dropdown.[1]("Choice 3");
dropdown.[2](1);
Drag options to blanks, or click blank then click option'
AselectByVisibleText
BselectByValue
CselectByIndex
DselectByName
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up selectByValue with selectByVisibleText.
Using wrong method names like selectByName.
5fill in blank
hard

Fill all three blanks to select options by value, visible text, and index in order.

Selenium Java
Select dropdown = new Select(driver.findElement(By.name("options")));
dropdown.[1]("v1");
dropdown.[2]("Option 2");
dropdown.[3](0);
Drag options to blanks, or click blank then click option'
AselectByValue
BselectByVisibleText
CselectByIndex
DselectById
Attempts:
3 left
💡 Hint
Common Mistakes
Using selectById which does not exist.
Mixing up the order of method calls.