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

Web pages alert, confirm and print functions #322

Open
ferpasri opened this issue Jan 9, 2023 · 0 comments
Open

Web pages alert, confirm and print functions #322

ferpasri opened this issue Jan 9, 2023 · 0 comments

Comments

@ferpasri
Copy link
Member

ferpasri commented Jan 9, 2023

TESTAR disables by default the functionality of alert(), confirm(), and print() functions in the javascript class that is loaded within the web plugin:

// Disallow browser dialogs
window.alert = function () {};
window.confirm = function () {};
window.print = function () {};

Example in which the alert dialog is disabled: https://demo.guru99.com/test/delete_customer.php

However, if some of these pop-up dialogs run inside an iframe element, TESTAR is not disabling the functionality by default. Still, it forces the focus on the main page of the SUT by using a webdriver.switchTo() method:

public static void activate() {
updateHandlesList();
// Nothing to activate, or user doesn't want to use this activate feature
if (windowHandles.size() < 1 || !forceActivateTab) {
return;
}
String handle = windowHandles.get(followLinks ? windowHandles.size() - 1 : 0);
try {
remoteWebDriver.switchTo().window(handle);
}
catch (NullPointerException | WebDriverException ignored) {
remoteWebDriver = null;
}
}

Example in which the alert dialog is not disabled because it is part of an iframe: https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert

Possible solution:
It is possible to adapt the TESTAR code to allow the execution of these dialogs and to at least extract the text information before closing it.
https://github.com/TESTARtool/TESTAR_dev/tree/webdriver_alerts

Future:
We need to improve this feature, consider the dialog a new state, and automatically derive a confirmation action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant