当前位置: 首页>>代码示例>>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;未经允许,请勿转载。