MOBILE-3833 behat: Wait for scroll before click
parent
d0d900e91b
commit
fe2c4474a9
|
@ -515,12 +515,20 @@
|
||||||
*
|
*
|
||||||
* @param {HTMLElement} element Element to press.
|
* @param {HTMLElement} element Element to press.
|
||||||
*/
|
*/
|
||||||
const pressElement = function(element) {
|
const pressElement = async function(element) {
|
||||||
// Scroll the item into view.
|
// Scroll the item into view.
|
||||||
|
const initialRect = element.getBoundingClientRect();
|
||||||
|
|
||||||
element.scrollIntoView(false);
|
element.scrollIntoView(false);
|
||||||
|
|
||||||
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
||||||
|
|
||||||
const rect = element.getBoundingClientRect();
|
const rect = element.getBoundingClientRect();
|
||||||
|
|
||||||
|
if (initialRect.y !== rect.y) {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 300));
|
||||||
|
}
|
||||||
|
|
||||||
// Simulate a mouse click on the button.
|
// Simulate a mouse click on the button.
|
||||||
const eventOptions = {
|
const eventOptions = {
|
||||||
clientX: rect.left + rect.width / 2,
|
clientX: rect.left + rect.width / 2,
|
||||||
|
|
Loading…
Reference in New Issue