Class MuiSlider

  • All Implemented Interfaces:
    com.github.grossopa.selenium.core.component.WebComponent, org.openqa.selenium.interactions.Locatable, org.openqa.selenium.internal.HasIdentity, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.WebElement, org.openqa.selenium.WrapsDriver, org.openqa.selenium.WrapsElement

    public class MuiSlider
    extends AbstractMuiComponent
    A MUI Slider wrapper.
    Since:
    1.0
    Author:
    Jack Yin
    See Also:
    https://material-ui.com/components/slider/
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.function.UnaryOperator<Double> DEFAULT_INVERSE_SCALE_FUNCTION  
      • Fields inherited from class com.github.grossopa.selenium.core.component.DefaultWebComponent

        driver
      • Fields inherited from class com.github.grossopa.selenium.core.component.AbstractDelegatedWebElement

        element
    • Constructor Summary

      Constructors 
      Constructor Description
      MuiSlider​(org.openqa.selenium.WebElement element, com.github.grossopa.selenium.core.ComponentWebDriver driver, MuiConfig config)
      Constructs an instance with the delegated element and root driver
      MuiSlider​(org.openqa.selenium.WebElement element, com.github.grossopa.selenium.core.ComponentWebDriver driver, MuiConfig config, java.util.function.UnaryOperator<Double> inverseScaleFunction)
      Constructs an instance with the delegated element, root driver and customized scale function.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      List<MuiSliderThumb> getAllThumbs()
      Gets the all Thumb elements.
      String getComponentName()
      Gets the current component name
      MuiSliderThumb getFirstThumb()
      Gets the first Thumb element.
      java.util.function.Function<Double,​Double> getInverseScaleFunction()
      Gets the inverse scale function
      String getMaxValue()
      Gets raw max value.
      Double getMaxValueDouble()
      Gets max value in Double.
      Integer getMaxValueInteger()
      Gets max value in Integer.
      Long getMaxValueLong()
      Gets max value in Long.
      String getMinValue()
      Gets raw min value.
      Double getMinValueDouble()
      Gets min value in Double.
      Integer getMinValueInteger()
      Gets min value in Integer.
      Long getMinValueLong()
      Gets min value in Long.
      String getValue()
      Gets the raw value.
      Double getValueDouble()
      Gets value in Double.
      Integer getValueInteger()
      Gets value in Integer.
      Long getValueLong()
      Gets value in Long.
      boolean isInverted()
      Is the slider tracker inverted.
      boolean isVertical()
      Is the slider vertical.
      void moveThumb​(double percentage)
      Moves the first thumb to the desired location in percentage.
      void moveThumb​(int index, double percentage)
      Moves the thumb to the desired location in percentage.
      void moveThumb​(MuiSliderThumb thumb, double percentage)
      Moves the thumb to the desired location in percentage.
      void setValue​(int index, Double value)
      Move the target thumb to the specified value in double.
      void setValue​(int index, Integer value)
      Move the target thumb to the specified value in Integer.
      void setValue​(int index, Long value)
      Move the target thumb to the specified value in long.
      void setValue​(MuiSliderThumb thumb, Double value)
      Move the target thumb to the specified value in double.
      void setValue​(MuiSliderThumb thumb, Integer value)
      Move the target thumb to the specified value in Integer.
      void setValue​(MuiSliderThumb thumb, Long value)
      Move the target thumb to the specified value in long.
      void setValue​(Double value)
      Move the first thumb to the specified value in double.
      void setValue​(Integer value)
      Move the first thumb to the specified value in Integer.
      void setValue​(Long value)
      Move the first thumb by value.
      • Methods inherited from class com.github.grossopa.selenium.core.component.DefaultWebComponent

        as, attributeContains, findComponent, findComponentAs, findComponents, findComponentsAs, to
      • Methods inherited from class com.github.grossopa.selenium.core.component.AbstractDelegatedWebElement

        clear, click, findElement, findElements, getAttribute, getCoordinates, getCssValue, getId, getLocation, getRect, getScreenshotAs, getSize, getTagName, getText, getWrappedDriver, getWrappedElement, isDisplayed, isSelected, sendKeys, submit, toString
      • Methods inherited from interface org.openqa.selenium.internal.HasIdentity

        getId
      • Methods inherited from interface org.openqa.selenium.interactions.Locatable

        getCoordinates
      • Methods inherited from interface org.openqa.selenium.TakesScreenshot

        getScreenshotAs
      • Methods inherited from interface com.github.grossopa.selenium.core.component.WebComponent

        findElement, findElements
      • Methods inherited from interface org.openqa.selenium.WebElement

        clear, click, getAttribute, getCssValue, getLocation, getRect, getSize, getTagName, getText, isDisplayed, isSelected, sendKeys, submit
      • Methods inherited from interface org.openqa.selenium.WrapsDriver

        getWrappedDriver
      • Methods inherited from interface org.openqa.selenium.WrapsElement

        getWrappedElement
    • Field Detail

      • DEFAULT_INVERSE_SCALE_FUNCTION

        public static final java.util.function.UnaryOperator<Double> DEFAULT_INVERSE_SCALE_FUNCTION
    • Constructor Detail

      • MuiSlider

        public MuiSlider​(org.openqa.selenium.WebElement element,
                         com.github.grossopa.selenium.core.ComponentWebDriver driver,
                         MuiConfig config)
        Constructs an instance with the delegated element and root driver
        Parameters:
        element - the delegated element
        driver - the root driver
        config - the Material UI configuration
      • MuiSlider

        public MuiSlider​(org.openqa.selenium.WebElement element,
                         com.github.grossopa.selenium.core.ComponentWebDriver driver,
                         MuiConfig config,
                         java.util.function.UnaryOperator<Double> inverseScaleFunction)
        Constructs an instance with the delegated element, root driver and customized scale function.
        Parameters:
        element - the delegated element
        driver - the root driver
        config - the Material UI configuration
        inverseScaleFunction - the INVERSE function of the original scale function
    • Method Detail

      • getInverseScaleFunction

        public java.util.function.Function<Double,​Double> getInverseScaleFunction()
        Gets the inverse scale function
        Returns:
        the inverse scale function
      • getValue

        public String getValue()
        Gets the raw value.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then it should return 59049

        Returns:
        the raw value in String.
      • getValueInteger

        public Integer getValueInteger()
        Gets value in Integer.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then it should return 59049

        Returns:
        the value in Integer.
      • getValueLong

        public Long getValueLong()
        Gets value in Long.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then it should return 59049

        Returns:
        the value in Long
      • getValueDouble

        public Double getValueDouble()
        Gets value in Double.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then it should return 59049

        Returns:
        the value in double
      • getMinValue

        public String getMinValue()
        Gets raw min value.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={2}, max={8}, scale={(x) => x ** 10}, then it should return 1024

        Returns:
        the raw min value.
      • getMinValueInteger

        public Integer getMinValueInteger()
        Gets min value in Integer.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={2}, max={8}, scale={(x) => x ** 10}, then it should return 1024

        Returns:
        the min value in Integer.
      • getMinValueLong

        public Long getMinValueLong()
        Gets min value in Long.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={2}, max={8}, scale={(x) => x ** 10}, then it should return 1024

        Returns:
        the min value in Long
      • getMinValueDouble

        public Double getMinValueDouble()
        Gets min value in Double.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={2}, max={8}, scale={(x) => x ** 10}, then it should return 1024

        Returns:
        the min value in double
      • getMaxValue

        public String getMaxValue()
        Gets raw max value.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then it should return 60466176

        Returns:
        the raw max value.
      • getMaxValueInteger

        public Integer getMaxValueInteger()
        Gets max value in Integer.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then it should return 60466176

        Returns:
        the max value in Integer.
      • getMaxValueLong

        public Long getMaxValueLong()
        Gets max value in Long.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then it should return 60466176

        Returns:
        the max value in Long
      • getMaxValueDouble

        public Double getMaxValueDouble()
        Gets max value in Double.

        If the slider is with scale function configured, it will return the scaled value, for example, when the position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then it should return 60466176

        Returns:
        the max value in double
      • getFirstThumb

        public MuiSliderThumb getFirstThumb()
        Gets the first Thumb element.
        Returns:
        the first Thumb element.
      • getAllThumbs

        public List<MuiSliderThumb> getAllThumbs()
        Gets the all Thumb elements. they are sorted by the value in ascending order.
        Returns:
        the all Thumb elements.
      • isVertical

        public boolean isVertical()
        Is the slider vertical.
        Returns:
        true if the slider has orientation="vertical" specified.
      • isInverted

        public boolean isInverted()
        Is the slider tracker inverted.
        Returns:
        true if the slide has track="inverted" specified.
      • setValue

        public void setValue​(Integer value)
        Move the first thumb to the specified value in Integer.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified value may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately set the value as 555 as the only possible locations are 55px and 56px for 550 and 560.

        If the slider is with scale function configured, it will accept the value as scaled value, for example, when when the expected position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then the value should be 59049

        Parameters:
        value - the new integer value to set
        See Also:
        moveThumb(double)
      • setValue

        public void setValue​(int index,
                             Integer value)
        Move the target thumb to the specified value in Integer. Note the MUI thumb is always ordered by value in ascending order.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified value may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately set the value as 555 as the only possible locations are 55px and 56px for 550 and 560.

        If the slider is with scale function configured, it will accept the value as scaled value, for example, when when the expected position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then the value should be 59049

        Parameters:
        index - the thumb index
        value - the new integer value to set
        See Also:
        moveThumb(double)
      • setValue

        public void setValue​(MuiSliderThumb thumb,
                             Integer value)
        Move the target thumb to the specified value in Integer.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified value may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately set the value as 555 as the only possible locations are 55px and 56px for 550 and 560.

        If the slider is with scale function configured, it will accept the value as scaled value, for example, when when the expected position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then the value should be 59049

        Parameters:
        thumb - the target thumb to move
        value - the new double value to set
        See Also:
        moveThumb(double)
      • setValue

        public void setValue​(Long value)
        Move the first thumb by value.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified value may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately set the value as 555 as the only possible locations are 55px and 56px for 550 and 560.

        If the slider is with scale function configured, it will accept the value as scaled value, for example, when when the expected position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then the value should be 59049

        Parameters:
        value - the new long value to set
        See Also:
        moveThumb(double)
      • setValue

        public void setValue​(int index,
                             Long value)
        Move the target thumb to the specified value in long. Note the MUI thumb is always ordered by value in ascending order.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified value may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately set the value as 555 as the only possible locations are 55px and 56px for 550 and 560.

        If the slider is with scale function configured, it will accept the value as scaled value, for example, when when the expected position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then the value should be 59049

        Parameters:
        index - the thumb index
        value - the new integer value to set
        See Also:
        moveThumb(double)
      • setValue

        public void setValue​(MuiSliderThumb thumb,
                             Long value)
        Move the target thumb to the specified value in long.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified value may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately set the value as 555 as the only possible locations are 55px and 56px for 550 and 560.

        If the slider is with scale function configured, it will accept the value as scaled value, for example, when when the expected position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then the value should be 59049

        Parameters:
        thumb - the target thumb to move
        value - the new double value to set
        See Also:
        moveThumb(double)
      • setValue

        public void setValue​(Double value)
        Move the first thumb to the specified value in double.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified value may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately set the value as 555 as the only possible locations are 55px and 56px for 550 and 560.

        If the slider is with scale function configured, it will accept the value as scaled value, for example, when when the expected position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then the value should be 59049

        Parameters:
        value - the new double value to set
        See Also:
        moveThumb(double)
      • setValue

        public void setValue​(int index,
                             Double value)
        Move the target thumb to the specified value in double. Note the MUI thumb is always ordered by value in ascending order.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified value may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately set the value as 555 as the only possible locations are 55px and 56px for 550 and 560.

        If the slider is with scale function configured, it will accept the value as scaled value, for example, when when the expected position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then the value should be 59049

        Parameters:
        index - the thumb index
        value - the new double value to set
        See Also:
        moveThumb(double)
      • setValue

        public void setValue​(MuiSliderThumb thumb,
                             Double value)
        Move the target thumb to the specified value in double.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified value may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately set the value as 555 as the only possible locations are 55px and 56px for 550 and 560.

        If the slider is with scale function configured, it will accept the value as scaled value, for example, when when the expected position is at 50%, min={0}, max={6}, scale={(x) => x ** 10}, then the value should be 59049

        Parameters:
        thumb - the target thumb to move
        value - the new double value to set
        See Also:
        moveThumb(double)
      • moveThumb

        public void moveThumb​(double percentage)
        Moves the first thumb to the desired location in percentage.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified percentage may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately move the thumb to a position like 55.5% for value 555 as the only possible locations are 55px and 56px for 550 and 560.

        Parameters:
        percentage - the percentage to move to, must between [0.0, 1.0]
      • moveThumb

        public void moveThumb​(int index,
                              double percentage)
        Moves the thumb to the desired location in percentage.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified percentage may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately move the thumb to a position like 55.5% for value 555 as the only possible locations are 55px and 56px for 550 and 560.

        Parameters:
        index - the index of the thumbs
        percentage - the percentage to move to, must between [0.0, 1.0]
      • moveThumb

        public void moveThumb​(MuiSliderThumb thumb,
                              double percentage)
        Moves the thumb to the desired location in percentage.

        Please note that due to this action is to simulate the user web page behaviour so it is possible that the specified percentage may not accurately reflect the real value, an example is that:

        • min value : 0
        • min value : 1000
        • slide width: 100px

        so it is not possible to accurately move the thumb to a position like 55.5% for value 555 as the only possible locations are 55px and 56px for 550 and 560.

        Parameters:
        thumb - the thumb component to move
        percentage - the percentage to move to, must between [0.0, 1.0]