TESTAR_dev icon indicating copy to clipboard operation
TESTAR_dev copied to clipboard

Web pages alert, confirm and print functions

Open ferpasri opened this issue 2 years ago • 0 comments

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

https://github.com/TESTARtool/TESTAR_dev/blob/6007a958999dca3ec724771b6157c119786c691c/webdriver/resources/web-extension/js/testar.init.start.js#L64-L67

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:

https://github.com/TESTARtool/TESTAR_dev/blob/6007a958999dca3ec724771b6157c119786c691c/webdriver/src/org/testar/monkey/alayer/webdriver/WdDriver.java#L425-L440

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.

ferpasri avatar Jan 09 '23 09:01 ferpasri