Quantcast
Channel: Grafana k6 - Grafana Labs Community Forums
Viewing all articles
Browse latest Browse all 335

Mouse hover in the page now working

$
0
0

@ankur I want to move the mouse cursor to disappear the pop up menu list to interact with the elements inside the iframe.

async clickLoginBtn() {
        await this.loginBtn.waitFor();
        console.log('Login button found');

        await Promise.all([
            this.page.waitForNavigation({ waitUntil: 'networkidle', timeout: 10000 }),
            this.loginBtn.click()
        ]);

        await this.tools.click();
        await Promise.all([
            this.page.waitForNavigation({ waitUntil: 'networkidle', timeout: 10000 }),
            this.configuration.click()
        ]);

        // Get the dimensions of the viewport
        const viewportSize = await page.viewportSize();

        // Move the mouse to the center of the screen
        await page.mouse.move(viewportSize.width / 2, viewportSize.height / 2);

        // Perform a hover action (simulated by moving the mouse slightly)
        await page.mouse.move(viewportSize.width / 2 + 1, viewportSize.height / 2 + 1);

        // Optional: Click after hovering
        await page.mouse.click(viewportSize.width / 2 + 1, viewportSize.height / 2 + 1);

        // Locate the iframe
        const iframeElement = await page.$('#admin_frame');

        // Get the Frame object for the iframe
        const frame = await iframeElement.contentFrame();

        // Now you can interact with elements inside the iframe
        const elementInsideIframe = await frame.$('#mat-input-0');
        await elementInsideIframe.fill('test');
    }

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 335

Trending Articles