You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-10Lines changed: 14 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,25 @@
1
-
# SeleniumDynamicMoveSlider
1
+
# Selenium Sliders Library -by James
2
+
3
+
2
4
Small library for manipulating sliders by simply passing the amount you want to move the slider to using the Selenium Web Driver
3
5
4
6
if you know that the incriment of the slider will be constant then simply pass them through the MoveSliderWithInfo Subroutine, This takes in the Max & Min values, Incriment, and the slider & selenium driver as arguments as well as the amount you want to move the slider to for assertion testing, use in a forloop with the data you have to assert against and save a heck-load of time :).
**The next 3 methods are used for specifying a numerical amount, converting it to a pixel value and then moving the slider specified, this is very useful if you only have test data in actual amounts instead of pixel values**
MoveSliderWithInfo(int SliderMax, int SliderMin, decimal Amount, IWebElement Slider, IWebDriver driver)
13
17
14
18
supply the method with the maximum value of the slider (what is actually output to the user), the mininum value of the slider, the amount you want the slider moved to, the slider you want moved as an IWebElement and the driver being used as an IWebDriver.
15
19
16
20
Comes with overloads for Amount in any numerical format or as a string with a basic non-numerical symbol removal filter
@@ -24,7 +28,7 @@ This is meant to be used when you do not know the maximum or mininum values of t
24
28
Supply the method with the driver being used, the slider you want moved and the amount as a dynamic, the method will then construct the values from the slider element to call the MoveSliderWithInfo and move the slider to the amount specified above.
@@ -33,27 +37,27 @@ This is meant to be used when you don't know the maximum or mininum values of th
33
37
It employs a basic filter method that removes any non numerical symbols which I wrote myself, this is an almost worst case scenario method where the user will not know the max/min values in the browser and they are not explicity contained inside the IwebElement, it however does work as well as any other method listed above provided the correct information is passed to it.
MoveSlider(IWebElement Slider, IWebDriver driver, int Pixels)
39
43
40
44
This is what's called to actually move the slider, If you already know the exact pixel value from the mininum that the slider has to move then you are able to directly call this subroutine and it will move the slider to the positon you want it to be but otherwise call the most appropriate method from above to do the amount to pixel conversion and movement automatically
This is used for taking an input, removing any non-numerical characters and returning the result as a decimal. This is used primarily in the "MoveSliderUsingTextBox" subroutine where the actual output from the slider through the speicfied textbox is used to calculate the amount of pixels necessary to move the slider. For example if you had a slider which output £2,000.00, the £ and , would throw an illegal input exception, this subroutine means that the program only sees "2000.00" as it only keeps numbers 0-> 9 and a decimal point.
@@ -62,7 +66,7 @@ This is where the majority of the mathematical calculation is done, using a math
62
66
This is the most vital and most versatile part of the program as it allows the user to input an amount e.g. £2000 and get the exact number of pixels the slider must be moved by as if the user asked the computer to move the slider £2000 across it would have no idea how to handle it. This allows a raw amount to be converted to a pixel value to maximum usability.
I made this for a placement last month and thought it was okay enough to put up here, equation for converting amount to a pixel value was done by me, ClickAndHold was done by a senior software engineer Declan McGill, I have to thank him for his help making this.
0 commit comments