@@ -52,6 +52,7 @@ public class Actions : IAction
52
52
private ActionBuilder actionBuilder = new ActionBuilder ( ) ;
53
53
private PointerInputDevice defaultMouse = new PointerInputDevice ( PointerKind . Mouse , "default mouse" ) ;
54
54
private KeyInputDevice defaultKeyboard = new KeyInputDevice ( "default keyboard" ) ;
55
+ private WheelInputDevice defaultWheel = new WheelInputDevice ( "default wheel" ) ;
55
56
private IActionExecutor actionExecutor ;
56
57
57
58
/// <summary>
@@ -417,8 +418,7 @@ public Actions DragAndDropToOffset(IWebElement source, int offsetX, int offsetY)
417
418
/// <returns>A self-reference to this <see cref="Actions"/>.</returns>
418
419
public Actions ScrollToElement ( IWebElement element )
419
420
{
420
- WheelInputDevice wheel = new WheelInputDevice ( ) ;
421
- this . actionBuilder . AddAction ( wheel . CreateWheelScroll ( element , 0 , 0 , 0 , 0 , DefaultScrollDuration ) ) ;
421
+ this . actionBuilder . AddAction ( this . defaultWheel . CreateWheelScroll ( element , 0 , 0 , 0 , 0 , DefaultScrollDuration ) ) ;
422
422
423
423
return this ;
424
424
}
@@ -431,8 +431,7 @@ public Actions ScrollToElement(IWebElement element)
431
431
/// <returns>A self-reference to this <see cref="Actions"/>.</returns>
432
432
public Actions ScrollByAmount ( int deltaX , int deltaY )
433
433
{
434
- WheelInputDevice wheel = new WheelInputDevice ( ) ;
435
- this . actionBuilder . AddAction ( wheel . CreateWheelScroll ( deltaX , deltaY , DefaultScrollDuration ) ) ;
434
+ this . actionBuilder . AddAction ( this . defaultWheel . CreateWheelScroll ( deltaX , deltaY , DefaultScrollDuration ) ) ;
436
435
437
436
return this ;
438
437
}
@@ -452,21 +451,19 @@ public Actions ScrollByAmount(int deltaX, int deltaY)
452
451
/// <exception cref="MoveTargetOutOfBoundsException">If the origin with offset is outside the viewport.</exception>
453
452
public Actions ScrollFromOrigin ( WheelInputDevice . ScrollOrigin scrollOrigin , int deltaX , int deltaY )
454
453
{
455
- WheelInputDevice wheel = new WheelInputDevice ( ) ;
456
-
457
454
if ( scrollOrigin . Viewport && scrollOrigin . Element != null )
458
455
{
459
456
throw new ArgumentException ( "viewport can not be true if an element is defined." , nameof ( scrollOrigin ) ) ;
460
457
}
461
458
462
459
if ( scrollOrigin . Viewport )
463
460
{
464
- this . actionBuilder . AddAction ( wheel . CreateWheelScroll ( CoordinateOrigin . Viewport ,
461
+ this . actionBuilder . AddAction ( this . defaultWheel . CreateWheelScroll ( CoordinateOrigin . Viewport ,
465
462
scrollOrigin . XOffset , scrollOrigin . YOffset , deltaX , deltaY , DefaultScrollDuration ) ) ;
466
463
}
467
464
else
468
465
{
469
- this . actionBuilder . AddAction ( wheel . CreateWheelScroll ( scrollOrigin . Element ,
466
+ this . actionBuilder . AddAction ( this . defaultWheel . CreateWheelScroll ( scrollOrigin . Element ,
470
467
scrollOrigin . XOffset , scrollOrigin . YOffset , deltaX , deltaY , DefaultScrollDuration ) ) ;
471
468
}
472
469
0 commit comments