Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Test Highcharts with selenium webdriver
- # Get the origin and datapoints of the first line
- s = selenium.get_eval("window.jQuery('svg g.highcharts-tracker path:eq(0)')")
- splitted = re.split('s+Ls+', s)
- origin = splitted[0].split(' ')[1:]
- data = [p.split(' ') for p in splitted[1:]]
- # Convert to floats
- origin = [float(origin[1]), float(origin[2])]
- data = [[float(x), float(y)] for x, y in data]
- # Get the min and max y-axis value and position
- min_y_val = float(selenium.get_eval(
- "window.jQuery('svg g.highcharts-axis:eq(1) text:first').text()")
- max_y_val = float(selenium.get_eval(
- "window.jQuery('svg g.highcharts-axis:eq(1) text:last').text()")
- min_y_pos = float(selenium.get_eval(
- "window.jQuery('svg g.highcharts-axis:eq(1) text:first').attr('y')")
- max_y_pos = float(selenium.get_eval(
- "window.jQuery('svg g.highcharts-axis:eq(1) text:last').attr('y')")
- # Calculate the value based on the retrieved positions
- y_scale = min_y_pos - max_y_pos
- y_range = max_y_val - min_y_val
- y_percentage = data[0][1] * 100.0 / y_scale
- value = max_y_val - (y_range * percentage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement