Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Close overlays that may be blocking a submit click
Browse files Browse the repository at this point in the history
  • Loading branch information
dicksnel committed Apr 4, 2023
1 parent 75e4620 commit 8eabe00
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions zap_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import traceback
import requests
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from selenium.common.exceptions import NoSuchElementException, TimeoutException, ElementClickInterceptedException
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import browserstorage
Expand Down Expand Up @@ -217,8 +218,16 @@ def login(self):

# if the OTP field was not found, we probably need to submit to go to the OTP page
# login flow: username -> next -> password -> next -> otp -> submit
self.submit_form(self.config.auth_submitaction,
self.config.auth_submit_field_name, username_element)
try:
self.submit_form(self.config.auth_submitaction,
self.config.auth_submit_field_name, username_element)
except ElementClickInterceptedException:
# If the submit click was intercepted, a popup maybe open, press Escape to close and try again.
bodyElement = self.driver.find_element_by_xpath("//body")
bodyElement.send_keys(Keys.Escape)
self.submit_form(self.config.auth_submitaction,
self.config.auth_submit_field_name, username_element)

self.fill_otp()

# submit
Expand Down

0 comments on commit 8eabe00

Please sign in to comment.