Advertisement
Guest User

Untitled

a guest
May 20th, 2012
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. Test Highcharts with selenium webdriver
  2. # Get the origin and datapoints of the first line
  3. s = selenium.get_eval("window.jQuery('svg g.highcharts-tracker path:eq(0)')")
  4. splitted = re.split('s+Ls+', s)
  5. origin = splitted[0].split(' ')[1:]
  6. data = [p.split(' ') for p in splitted[1:]]
  7. # Convert to floats
  8. origin = [float(origin[1]), float(origin[2])]
  9. data = [[float(x), float(y)] for x, y in data]
  10.  
  11. # Get the min and max y-axis value and position
  12. min_y_val = float(selenium.get_eval(
  13. "window.jQuery('svg g.highcharts-axis:eq(1) text:first').text()")
  14. max_y_val = float(selenium.get_eval(
  15. "window.jQuery('svg g.highcharts-axis:eq(1) text:last').text()")
  16. min_y_pos = float(selenium.get_eval(
  17. "window.jQuery('svg g.highcharts-axis:eq(1) text:first').attr('y')")
  18. max_y_pos = float(selenium.get_eval(
  19. "window.jQuery('svg g.highcharts-axis:eq(1) text:last').attr('y')")
  20.  
  21. # Calculate the value based on the retrieved positions
  22. y_scale = min_y_pos - max_y_pos
  23. y_range = max_y_val - min_y_val
  24. y_percentage = data[0][1] * 100.0 / y_scale
  25. value = max_y_val - (y_range * percentage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement