Class SelectBoxUtils

java.lang.Object
uk.co.evoco.webdriver.utils.TolerantInteraction
uk.co.evoco.webdriver.utils.SelectBoxUtils

public final class SelectBoxUtils
extends TolerantInteraction
Utilities class providing support methods for Select Boxes While this is straight forward, its less than obvious to newcomers. Feel free not to use this at all and just do it with WebDriver!
  • Constructor Summary

    Constructors 
    Constructor Description
    SelectBoxUtils()  
  • Method Summary

    Modifier and Type Method Description
    static void itemByHtmlValueAttribute​(org.openqa.selenium.WebElement selectBox, java.lang.String htmlValue)
    Selects an option that has a matching value attribute in the Options tag markup
    static void itemByIndex​(org.openqa.selenium.WebElement selectBox, int index)
    Selects an option by the index of the option in the list.
    static void itemByVisibleText​(org.openqa.selenium.WebElement selectBox, java.lang.String visibleText)
    Selects an option by the text that is visible in the select box
    static void tolerantItemByHtmlValueAttribute​(org.openqa.selenium.WebElement webElement, java.lang.String htmlValue)  
    static void tolerantItemByHtmlValueAttribute​(org.openqa.selenium.WebElement webElement, java.lang.String htmlValue, int timeout)  
    static void tolerantItemByIndex​(org.openqa.selenium.WebElement webElement, int index)  
    static void tolerantItemByIndex​(org.openqa.selenium.WebElement webElement, int index, int timeout)  
    static void tolerantItemByVisibleText​(org.openqa.selenium.WebElement webElement, java.lang.String visibleText)  
    static void tolerantItemByVisibleText​(org.openqa.selenium.WebElement webElement, java.lang.String visibleText, int timeout)  

    Methods inherited from class uk.co.evoco.webdriver.utils.TolerantInteraction

    tolerantInteraction, tolerantInteraction, tolerantInteraction

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • itemByHtmlValueAttribute

      public static void itemByHtmlValueAttribute​(org.openqa.selenium.WebElement selectBox, java.lang.String htmlValue)
      Selects an option that has a matching value attribute in the Options tag markup
      Parameters:
      selectBox - active WebElement, already located
      htmlValue - HTML value attribute
    • itemByIndex

      public static void itemByIndex​(org.openqa.selenium.WebElement selectBox, int index)
      Selects an option by the index of the option in the list. The input is NOT zero based, we're normalising the input internally.
      Parameters:
      selectBox - active WebElement, already located
      index - index in order of display
    • itemByVisibleText

      public static void itemByVisibleText​(org.openqa.selenium.WebElement selectBox, java.lang.String visibleText)
      Selects an option by the text that is visible in the select box
      Parameters:
      selectBox - active WebElement, already located
      visibleText - visible text in the select box (NOT the HTML value attribute)
    • tolerantItemByHtmlValueAttribute

      public static void tolerantItemByHtmlValueAttribute​(org.openqa.selenium.WebElement webElement, java.lang.String htmlValue, int timeout) throws java.lang.Throwable
      Parameters:
      webElement - active WebElement, already located
      htmlValue - HTML value attribute
      timeout - time in seconds to keep trying
      Throws:
      java.lang.Throwable - any unhandled or un-tolerated exception
    • tolerantItemByHtmlValueAttribute

      public static void tolerantItemByHtmlValueAttribute​(org.openqa.selenium.WebElement webElement, java.lang.String htmlValue) throws java.lang.Throwable
      Parameters:
      webElement - active WebElement, already located
      htmlValue - HTML value attribute
      Throws:
      java.lang.Throwable - any unhandled or un-tolerated exception
    • tolerantItemByVisibleText

      public static void tolerantItemByVisibleText​(org.openqa.selenium.WebElement webElement, java.lang.String visibleText, int timeout) throws java.lang.Throwable
      Parameters:
      webElement - active WebElement, already located
      visibleText - visible text in the select box (NOT the HTML value attribute)
      timeout - time in seconds to keep trying
      Throws:
      java.lang.Throwable - any unhandled or un-tolerated exception
    • tolerantItemByVisibleText

      public static void tolerantItemByVisibleText​(org.openqa.selenium.WebElement webElement, java.lang.String visibleText) throws java.lang.Throwable
      Parameters:
      webElement - active WebElement, already located
      visibleText - visible text in the select box (NOT the HTML value attribute)
      Throws:
      java.lang.Throwable - any unhandled or un-tolerated exception
    • tolerantItemByIndex

      public static void tolerantItemByIndex​(org.openqa.selenium.WebElement webElement, int index, int timeout) throws java.lang.Throwable
      Parameters:
      webElement - active WebElement, already located
      index - index in order of display
      timeout - time in seconds to keep trying
      Throws:
      java.lang.Throwable - any unhandled or un-tolerated exception
    • tolerantItemByIndex

      public static void tolerantItemByIndex​(org.openqa.selenium.WebElement webElement, int index) throws java.lang.Throwable
      Parameters:
      webElement - active WebElement, already located
      index - index in order of display
      Throws:
      java.lang.Throwable - any unhandled or un-tolerated exception