How to handle browser Pop Up?
I have tried with acceptPopup and it isn’t working.
Also, I have tried with Esc key to avoid the pop-up but it isn’t working.
Can you pls help with the same.
@christian_wolf : let me know your views
Thanks in advance.
@Vish131 you cannot handle the popup using Webdriver (if that is your used helper) or other helper.
When you’re testing with Chrome, you can pass a parameter to disable notification completely.
See https://webkul.com/blog/handle-browser-level-notification-using-selenium/ for details.
in you codeceptjs config it should look something like this:
//…
helpers: {
WebDriver: {
url: url,
browser: “chrome”,
//…
desiredCapabilities: {
chromeOptions: {
args: ["—disable-notifications"]
}
}
},
//…
Vish131:
acceptPopup
Hi,
i want to accept the popup .so what should it would be .
Thanks
you cannot accept the popup as far a s i know because it’s a system (windows/lonux/MacOS?) popup and therfor you must disable it.
Yes, I will work on this and share my observations as well.
As of now after adding the code with args : ["—disable-notifications"] ,
the pop-up is still visible.
Thanks mate for quick response
@Vish131
I do this way for Chrome + WebDriver
conf.desiredCapabilities.chromeOptions = {
prefs: {
profile: {
default_content_settings: {
popups: 0,
},
},
},
};
1 Like
Thanks @christian_wolf and @juancuervo … i would go through the suggestions and will provide what works for me in detail.
Cheers,
Vishal
gouri
August 13, 2020, 12:19pm
9
Hi, I tried using similar approach for setting default download directory in browser still it’s not working. Can you confirm if there are any changes required.
desiredCapabilities: {
chromeOptions: {
prefs: {
'download.default_directory': filePath,
},
},
},
},
Thanks
@gouri
This works for me
desiredCapabilities.chromeOptions = {
prefs: {
profile: {
default_content_settings: {
popups: 0,
},
default_content_setting_values: {
automatic_downloads: true,
},
},
download: {
default_directory: filePath,
prompt_for_download: false,
},
},
extensions: [],
};
1 Like
gouri
August 14, 2020, 10:59am
11
Hi,
Thank you so much for quick reply, solution mentioned above worked properly.
However to make it more dynamic i was trying to create folder before test execution and remove created folder after execution successfully completed.
Dynamic folder creation is working properly at runtime using following code snippet
_beforeSuite()
{
if (!Directory.Exists(downloadDir)){
newPath = Directory.CreateDirectory(downloadDir).FullName;
}
}
but Delete folder is not working at runtime, for which i tried following approaches
Similar to createDirectory i tried to use Directory.Delete in _afterSuite
Installed fs-extra module of npm and tried using remove function of file system in javascript but still folder is not getting deleted.
If you have handled dynamic folder creation at runtime can you please guide on same.
Thanks once again.