Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: <Alert closing automatically> #8351

Closed
3 tasks done
praveenngp15 opened this issue May 17, 2022 · 9 comments
Closed
3 tasks done

[🐛 Bug]: <Alert closing automatically> #8351

praveenngp15 opened this issue May 17, 2022 · 9 comments
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested Needs Investigation Issues that require more information on the problem.

Comments

@praveenngp15
Copy link

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

"@wdio/cli": "^7.19.3",

Node.js Version

16.15.0

Mode

WDIO Testrunner

Which capabilities are you using?

import { Suite } from '@wdio/types/build/Frameworks';
import * as fs from 'fs';

const video = require('wdio-video-reporter');

export let config: WebdriverIO.Config = {
    specs: ['./test/**/*.spec.ts'],
    suites: {
        login: ['./test/**/example.spec.ts']
    },

    capabilities: [
        {
            browserName: 'chrome',
            maxInstances: 1,
            'goog:chromeOptions': {
                args: ['--start-maximized']
            }
        }
    ],


    framework: 'Jasmine',
    logLevel: 'error',
    jasmineOpts: {
        defaultTimeoutInterval: 120000
    },
    reporters: [
        'dot',
        'spec',
        [
            'junit',
            {
                outputDir: './reports',
                outputFileFormat(options: { cid: any; capabilities: any }) {
                    // optional
                    return `results-${options.cid}.${options.capabilities}.xml`;
                }
            }
        ],
        [
            video,
            {
                saveAllVideos: true, // If true, also saves videos for successful test cases
                videoSlowdownMultiplier: 3 // Higher to get slower videos, lower for faster videos [Value 1-100]
            }
        ]
    ],

    onPrepare() {
        const dirJunit = `reports`;
        if (fs.existsSync(dirJunit)) {
            fs.rmdir(dirJunit, {recursive: true}, (err) => {
                if (err) {
                    throw err;
                }

                console.log(`${dirJunit} is deleted!`);
            });
        }

        const dirVideo = `_results_`;
        if (fs.existsSync(dirVideo)) {
            fs.rmdir(dirVideo, {recursive: true}, (err) => {
                if (err) {
                    throw err;
                }
                console.log(`${dirVideo} is deleted!`);
            });
        }
    },

    async beforeSuite(suite: Suite) {
    },

    async afterSuite(suite: Suite) {
        await browser.pause(20000);
    },
    services: ['chromedriver'],
    autoCompileOpts: {
        autoCompile: true,
        // for all available options
        tsNodeOpts: {
            transpileOnly: true,
            project: 'tsconfig.json'
        }
    }
};

What happened?

Alert is closing automatically

await browser.url('https://chercher.tech/practice/popups')
await $("//input[@name='alert']").click()
await browser.pause(10000)
await browser.acceptAlert()

So not able to accept or dismiss the alert

What is your expected behavior?

Alert should not close automatically

How to reproduce the bug.

await browser.url('https://chercher.tech/practice/popups')
await $("//input[@name='alert']").click()
await browser.pause(10000)
await browser.acceptAlert()

Relevant log output

no such alert: no such alert
  (Session info: chrome=101.0.4951.54)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues
@praveenngp15 praveenngp15 added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels May 17, 2022
@christian-bromann
Copy link
Member

@praveenngp15 thanks for raising the issue.

I am not sure how this is an issue with WebdriverIO 🤔 WebdriverIO doesn't automatically close alerts. Can you verify that your application doesn't do this?

@praveenngp15
Copy link
Author

When adding video reporter the alert is automatically accepting

const video = require('wdio-video-reporter');

reporters: ['spec',

[
    video,
    {
        saveAllVideos: true, // If true, also saves videos for successful test cases
        videoSlowdownMultiplier: 3 // Higher to get slower videos, lower for faster videos [Value 1-100]
    }
]

If reporter is not added it is working fine.

@christian-bromann
Copy link
Member

Can you create a mini project that reproduces this problem?

@christian-bromann christian-bromann added Reproducible Example Missing and removed Needs Triaging ⏳ No one has looked into the issue yet labels May 17, 2022
@praveenngp15
Copy link
Author

praveenngp15 commented May 17, 2022

@christian-bromann
Copy link
Member

Thanks, feel free to help us investigate this issue. Thank you!

@christian-bromann christian-bromann added Needs Investigation Issues that require more information on the problem. help wanted Issues that are free to take by anyone interested and removed Reproducible Example Missing labels May 17, 2022
@erwinheitzman
Copy link
Member

I have investigated the issue and the problem lies in making screenshots in the afterCommand hook which closes the alert.

@christian-bromann
Copy link
Member

Thanks for investigating @erwinheitzman

I assume one option could be that the video reporter checks wether an alert is open and if so skips the screenshot command.

@erwinheitzman
Copy link
Member

That would be a simple fix we could also look into other ways of creating videos

@christian-bromann
Copy link
Member

Raised an issue within the video reporter. Any contributions are appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested Needs Investigation Issues that require more information on the problem.
Projects
None yet
Development

No branches or pull requests

3 participants