Skip to content

Commit

Permalink
add otp selenium script
Browse files Browse the repository at this point in the history
Signed-off-by: Najam Ul Saqib <[email protected]>
  • Loading branch information
njmulsqb committed Mar 7, 2024
1 parent d30953b commit 5ae892c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions selenium/Fill OTP in MFA.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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

function browserLaunched(utils) {
var By = Java.type("org.openqa.selenium.By");
var Thread = Java.type("java.lang.Thread");
var url = utils.waitForURL(5000);
var wd = utils.getWebDriver();
var OTP = "123456";

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
Thread.sleep(1000);
wd.executeScript(
"document.querySelector('[aria-label=\"Verify Code\"]').click()"
);
}

0 comments on commit 5ae892c

Please sign in to comment.