Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Modify alert to wait page body

  • Loading branch information...
commit df44bc93a1c72b3059e1181eb20fbb79b6128c26 1 parent 60c91bc
@keitaoouchi authored
Showing with 14 additions and 4 deletions.
  1. +14 −4 src/seleniumwrapper/wrapper.py
View
18 src/seleniumwrapper/wrapper.py
@@ -11,7 +11,8 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import (NoSuchElementException, TimeoutException,
- WebDriverException, ElementNotVisibleException)
+ WebDriverException, ElementNotVisibleException,
+ NoAlertPresentException)
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
def create(drivername, *args, **kwargs):
@@ -115,7 +116,16 @@ def to_select(self):
@property
def alert(self):
- return self.switch_to_alert()
+ timeout = time.time() + 2
+ while time.time() < timeout:
+ try:
+ alert = self._driver.switch_to_alert()
+ alert.text
+ return alert
+ except NoAlertPresentException:
+ time.sleep(0.1)
+ msg = "Wait for alert to be displayed for 2 seconds, but it was not displayed."
+ raise NoAlertPresentException(msg)
def __getattribute__(self, name):
return object.__getattribute__(self, name)
@@ -191,8 +201,8 @@ def click(self, timeout=3, presleep=0, postsleep=0):
if presleep:
time.sleep(presleep)
self._wait_until_stopping(timeout, 0.1)
- self._wait_until_displayed(timeout, 0.5)
- self._wait_until_clickable(timeout, 0.5)
+ self._wait_until_displayed(timeout, 0.3)
+ self._wait_until_clickable(timeout, 0.3)
if postsleep:
time.sleep(postsleep)
except Exception as e:
Please sign in to comment.
Something went wrong with that request. Please try again.