@ Override public void dragToValue ( double value ) { logger . entering ( value ) ; WebElement webElement = findElement ( locator ) ; Point currentLocation = webElement . getLocation ( ) ; Dimension elementSize = webElement . getSize ( ) ; int x = currentLocation . getX ( ) ; int y = currentLocation . getY ( ) + ( elementSize . getHeight ( ) / 2 ) ; int pos = Double . valueOf ( value * ( elementSize . getWidth ( ) ) ) . intValue ( ) ; int endX = x + pos ; // full width will throw exception if ( value >= VALUE_UPPER_LIMIT ) { endX -- ; } // endX == 0 move to the middle if ( endX < MIN_END_X ) { endX = MIN_END_X ; } initBridgeDriver ( ) ; MobileNodeType mobileType = Grid . getMobileTestSession ( ) . getMobileNodeType ( ) ; if ( mobileType . equals ( MobileNodeType . APPIUM ) ) { // On Appium we use tap (TouchAction) instead driver . swipe ( 1 , endX , y , 100 ) ; } else { driver . swipe ( x , y , endX , y ) ; } logger . exiting ( ) ; }
it is not accurate and is best to used only for setting value to 0 or 1 otherwise the result is close to parameter