當前位置: 首頁>>代碼示例>>Python>>正文


Python exceptions.NoAlertPresentException方法代碼示例

本文整理匯總了Python中selenium.common.exceptions.NoAlertPresentException方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.NoAlertPresentException方法的具體用法?Python exceptions.NoAlertPresentException怎麽用?Python exceptions.NoAlertPresentException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在selenium.common.exceptions的用法示例。


在下文中一共展示了exceptions.NoAlertPresentException方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: AlertAccept

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def AlertAccept(self):
        logger.step_normal("AlertAccept()")

        time.sleep(2)
        try:
            logger.step_normal("switch_to_alert()")
            alert = Browser.RunningBrowser.switch_to_alert()
            alert.accept()
        except NoAlertPresentException:
            logger.step_normal("Alert Not Found. ")

        try:
            logger.step_normal("switch_to_default_content()")
            Browser.RunningBrowser.switch_to_default_content()
        except Exception as e:
            logger.step_warning(e)
            pass 
開發者ID:hw712,項目名稱:knitter,代碼行數:19,代碼來源:webelement.py

示例2: AlertDismiss

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def AlertDismiss(self):
        logger.step_normal("AlertDismiss()")

        time.sleep(2)
        try:
            logger.step_normal("switch_to_alert()")
            alert = Browser.RunningBrowser.switch_to_alert()
            alert.dismiss()
        except NoAlertPresentException:
            logger.step_normal("Alert Not Found.")

        try:
            logger.step_normal("switch_to_default_content()")
            Browser.RunningBrowser.switch_to_default_content()
        except Exception as e:
            logger.step_normal(e)
            pass 
開發者ID:hw712,項目名稱:knitter,代碼行數:19,代碼來源:webelement.py

示例3: _get

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def _get(browser, url, retries=5):
    try:
        browser.get(url)
        assert browser.get_cookies()
    except TimeoutException:
        if retries == 0:
            raise
        else:
            print("Failed to load '{}', trying again...".format(url))
            _get(browser, url, retries=retries - 1)

    try:
        alert = browser.switch_to.alert
    except NoAlertPresentException:
        pass
    else:
        print("Warning: dismissing unexpected alert ({})".format(alert.text))
        alert.accept() 
開發者ID:jupyter,項目名稱:nbgrader,代碼行數:20,代碼來源:formgrade_utils.py

示例4: is_alert_present

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def is_alert_present(self):
        try:
            self.driver.switch_to_alert()
        except NoAlertPresentException as e:
            return False
        return True 
開發者ID:vprusso,項目名稱:youtube_tutorials,代碼行數:8,代碼來源:selenium_ide_intro.py

示例5: alert_is_display

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def alert_is_display(self):
        """
        selenium API
        Determines if alert is displayed
        """
        try:
            self.driver.switch_to.alert
        except NoAlertPresentException:
            return False
        else:
            return True 
開發者ID:SeldomQA,項目名稱:poium,代碼行數:13,代碼來源:webdriver.py

示例6: close_all_windows_except_first

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def close_all_windows_except_first(driver):
    windows = driver.window_handles

    for window in windows[1:]:
        driver.switch_to_window(window)
        driver.close()

    while True:
        try:
            alert = driver.switch_to_alert()
            alert.dismiss()
        except (NoAlertPresentException, NoSuchWindowException):
            break

    driver.switch_to_window(windows[0]) 
開發者ID:marco-c,項目名稱:autowebcompat,代碼行數:17,代碼來源:collect.py

示例7: assert_alert_present

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def assert_alert_present(self):
        '''
        Asserts that an alert exists.

        '''
        alert = self.browser.switch_to_alert()
        msg = 'An alert was not present but was expected.'

        try:
            atext = bool(alert.text)
        except NoAlertPresentException:
            atext = False

        assert atext == True, msg 
開發者ID:IntuitiveWebSolutions,項目名稱:PyWebRunner,代碼行數:16,代碼來源:WebTester.py

示例8: assert_alert_not_present

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def assert_alert_not_present(self):
        '''
        Asserts that an alert does not exist.

        '''
        def check_text(alert):
            bool(alert.text)

        alert = self.browser.switch_to_alert()
        present = False
        try:
            present = bool(alert.text)
        except NoAlertPresentException:
            pass
        assert present == False 
開發者ID:IntuitiveWebSolutions,項目名稱:PyWebRunner,代碼行數:17,代碼來源:WebTester.py

示例9: is_alert_present

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def is_alert_present(self):
        try: self.driver.switch_to_alert()
        except NoAlertPresentException as e: return False
        return True 
開發者ID:mgard,項目名稱:epater,代碼行數:6,代碼來源:test.py

示例10: tearDown

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def tearDown(self):
        self.driver.get(self.base_url)
        try:  # pragma: no cover
            # Accept any "Are you sure to leave?" alert
            self.driver.switch_to.alert.accept()
            self.driver.switch_to.default_content()
        except NoAlertPresentException:
            pass
        WebDriverWait(self.driver, 10).until(lambda driver: self.base_url == driver.current_url)
        self.driver.delete_all_cookies()
        self.clearBBDD() 
開發者ID:conwetlab,項目名稱:ckanext-privatedatasets,代碼行數:13,代碼來源:test_selenium.py

示例11: is_alert_present

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def is_alert_present(self):
        try:
            self.get_alert_text()
            return True
        except NoAlertPresentException:
            return False 
開發者ID:wgnet,項目名稱:webium,代碼行數:8,代碼來源:windows_handler.py

示例12: accept_alert

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def accept_alert(self, ignore_not_present=False):
        """Accepts alert.

        :Args:
         - ignore_not_present: ignore NoAlertPresentException
        """
        try:
            self.switch_to.alert.accept()
        except NoAlertPresentException:
            if not ignore_not_present:
                raise 
開發者ID:golemhq,項目名稱:golem,代碼行數:13,代碼來源:extended_driver.py

示例13: alert_is_present

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def alert_is_present(self):
        """Returns whether an alert is present"""
        try:
            self.switch_to.alert
            return True
        except NoAlertPresentException:
            return False 
開發者ID:golemhq,項目名稱:golem,代碼行數:9,代碼來源:extended_driver.py

示例14: dismiss_alert

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def dismiss_alert(self, ignore_not_present=False):
        """Dismiss alert.

        :Args:
         - ignore_not_present: ignore NoAlertPresentException
        """
        try:
            self.switch_to.alert.dismiss()
        except NoAlertPresentException:
            if not ignore_not_present:
                raise 
開發者ID:golemhq,項目名稱:golem,代碼行數:13,代碼來源:extended_driver.py

示例15: assert_exists

# 需要導入模塊: from selenium.common import exceptions [as 別名]
# 或者: from selenium.common.exceptions import NoAlertPresentException [as 別名]
def assert_exists(self):
        try:
            self.alert = self.browser.driver.switch_to.alert
        except NoAlertPresentException:
            raise UnknownObjectException('unable to locate alert') 
開發者ID:watir,項目名稱:nerodia,代碼行數:7,代碼來源:alert.py


注:本文中的selenium.common.exceptions.NoAlertPresentException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。