Skip to content

Instantly share code, notes, and snippets.

@avuori
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avuori/a19abfdac42b09ad844b to your computer and use it in GitHub Desktop.
Save avuori/a19abfdac42b09ad844b to your computer and use it in GitHub Desktop.
def set_range(el, val):
minval = float(el.get_attribute("min") or 0)
maxval = float(el.get_attribute("max") or 100)
v = max(0, min(1, (float(val) - minval) / (maxval - minval)))
width = el.size["width"]
target = float(width) * v
ac = ActionChains(driver)
ac.move_to_element_with_offset(el, target, 1)
ac.click()
ac.perform()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment