diff --git a/selenium/FillOTPInMFA.js b/selenium/FillOTPInMFA.js index c9472173..12b92c9d 100644 --- a/selenium/FillOTPInMFA.js +++ b/selenium/FillOTPInMFA.js @@ -1,5 +1,8 @@ -// This script can be used to fill in the OTP if it appears right after the authentication. -// This can only work for the apps who have fixed OTP in MFA +/* +This script will fill the OTP if MFA is configured on web-app. Browser-based auth is the pre-requisite for this script. +You need to analyze DOM of the web app this script needs to run on and modify the parameters accordingly. +This script assumes that the web app has fixed OTP for testing which can be stored in the variable below. + */ function browserLaunched(utils) { var By = Java.type("org.openqa.selenium.By"); @@ -10,12 +13,7 @@ function browserLaunched(utils) { wd.get(url + "#/login"); Thread.sleep(30000); //Wait for ZAP to handle the auth. - wd.findElement(By.id("one-time-code")).sendKeys(OTP); - wd.executeScript( - "document.querySelector('flt-glass-pane').shadowRoot.querySelector('flt-semantics-placeholder').click({force: true})" - ); //Used with Flutter apps only + wd.findElement(By.id("one-time-code")).sendKeys(OTP); //Replace the input field as per your web-app's DOM Thread.sleep(1000); - wd.executeScript( - "document.querySelector('[aria-label=\"Verify Code\"]').click()" - ); + wd.executeScript("document.querySelector('[aria-label=\"Verify Code\"]').click()"); //Replace the submit label as per your web-app's DOM }