flood-io / element

💦Load test your app using real web browsers
https://element.flood.io
Apache License 2.0
350 stars 43 forks source link

Browser state lost between iterations #545

Open gaetan-wap opened 2 years ago

gaetan-wap commented 2 years ago

Describe the bug Logic implemented in Youtube example does not seem to work. Browser state seems to be lost between iterations

To Reproduce Run the following script:

import { step, TestSettings, Until, By, Device } from '@flood/element'
import * as assert from 'assert'

let setUp = 1

export const settings: TestSettings = {
    clearCache: true,
    disableCache: true,
    waitTimeout: '30s',
    screenshotOnFailure: true,
    stepDelay: '7.5s',
    actionDelay: '7.5s',
    incognito: false,
}

/**
 * youtube
 * @version 1.0
 */
export default () => {
    step('Test: Start', async browser => {
        if (setUp == 1) {
            console.log('Load video for the first time')
            await browser.visit('https://www.youtube.com/watch?v=6fvhLrBrPQI')

            // const btnPlay = await browser.findElement(
            //  By.xpath('//button[@class="ytp-large-play-button ytp-button"]')
            // )
            // btnPlay.click()

            await browser.takeScreenshot()

            setUp = 0
        } else {
            //Video page has already been opened
            //Check to see if the video has finished playing
            // try {
            //  await browser.wait(Until.elementIsVisible(By.xpath('//button[@title="Replay"]')))
            //  //If the video has finished, restart and reload video page again
            //  setUp = 1
            //  await browser.takeScreenshot()
            //  await console.log('Replaying video next iteration')
            // } catch {
            //  //Video is still playing
            //  await console.log('Video is still playing')
            //  await browser.takeScreenshot()
            await browser.takeScreenshot()
        }
    })
}

with :

element run --loop-count 2 youtube.ts

Expected behavior I expect to have two identical screenshots (one for each iteration)

Pb: Second screenshot is white (same as default browser state).

Screenshots

20Ri1ddHj260S78VRsIT3A1yWAs

20Ri3cRPMoUwCluXSRvN76JCi1A

Desktop (please complete the following information):

Additional context Add any other context about the problem here.