How to move Horizontal Slider or Vertical Slider of jQuery using Selenium Webdriver

0
0

I want to Make selenium script which move slider given on following site

Example name is How to change orientation of jQuery UI Slider

http://jqueryui.com/demos/slider/

I have no idea How to do this

  • You must to post comments
0
0

I worked out Python equivalent of Franz Ebner’s answer. Just in case if it helps someone

Notes:
In Python,

  1. find_element_by_XXX doesn’t find an element within a frame, unless
    you use switch_to_frame (Not sure about other languages )

  2. Negative (-) offset values don’t work as expected, hence moving only by the offset value calculated based on percentage passed to the method


def check(self, percent):
driver
= self.driver
driver
.get("http://jqueryui.com/demos/slider/");
driver
.switch_to_frame(0)
driver
.switch_to_active_element()
slidebar
= driver.find_element_by_id("slider")
height
= slidebar.size['height']
width
= slidebar.size['width']
move
= ActionChains(driver);
slider
= driver.find_element_by_xpath("//div[@id='slider']/a")
if width > height:
//highly likely a horizontal slider
move
.click_and_hold(slider).move_by_offset(percent * width / 100, 0).release().perform()
else:
//highly likely a vertical slider
move
.click_and_hold(slider).move_by_offset(percent * height / 100, 0).release().perform()
driver
.switch_to_default_content()
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website