Skip to content

Commit

Permalink
improve comments in the script
Browse files Browse the repository at this point in the history
Signed-off-by: Najam Ul Saqib <najamulsaqib@tutamail.com>
  • Loading branch information
njmulsqb committed Mar 7, 2024
1 parent c7f408f commit be6a86a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions selenium/FillOTPInMFA.js
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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
}

0 comments on commit be6a86a

Please sign in to comment.