Returns the x and y coordinates for the given slider value.
(slider: webdriver.WebElement, value: number)
| 175 | |
| 176 | /** Returns the x and y coordinates for the given slider value. */ |
| 177 | async function getCoordsForValue(slider: webdriver.WebElement, value: number): Promise<Point> { |
| 178 | const inputs = await slider.findElements(webdriver.By.css('.mdc-slider__input')); |
| 179 | |
| 180 | const min = Number(await inputs[0].getAttribute('min')); |
| 181 | const max = Number(await inputs[inputs.length - 1].getAttribute('max')); |
| 182 | const percent = (value - min) / (max - min); |
| 183 | |
| 184 | const {width, height} = await slider.getSize(); |
| 185 | |
| 186 | const x = Math.round(width * percent); |
| 187 | const y = Math.round(height / 2); |
| 188 | |
| 189 | return {x, y}; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Clicks an element at a specific point. Useful if there's another element |
no test coverage detected