Is using the Select element instead of physically doing 'element.click()' bad practice in Test Automation? Is using the Select element instead of physically doing 'element.click()' bad practice in Test Automation? selenium selenium

Is using the Select element instead of physically doing 'element.click()' bad practice in Test Automation?


nodes must be always handled through Select(webelement) class inducing WebDriverWait for the element_to_be_clickable(). As an example:

  • Using Java, cssSelector and selectByVisibleText():

    new Select(new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("selectElementCss")))).selectByVisibleText("visibleText");
  • Using Python, xpath and select_by_value():

    Select(WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "select_element_xpath")))).select_by_value("option_value")

References

You can find a couple of detailed discussions in: