MCPcopy Create free account
hub / github.com/angular/components / getCoordsForValue

Function getCoordsForValue

src/material/slider/slider.e2e.spec.ts:177–190  ·  view source on GitHub ↗

Returns the x and y coordinates for the given slider value.

(slider: webdriver.WebElement, value: number)

Source from the content-addressed store, hash-verified

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

Callers 3

focusSliderThumbFunction · 0.70
setValueByClickFunction · 0.70
slideToValueFunction · 0.70

Calls 2

getAttributeMethod · 0.65
getSizeMethod · 0.45

Tested by

no test coverage detected