当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.UnexpectedAlertPresentException方法代码示例

本文整理汇总了Python中selenium.common.exceptions.UnexpectedAlertPresentException方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.UnexpectedAlertPresentException方法的具体用法?Python exceptions.UnexpectedAlertPresentException怎么用?Python exceptions.UnexpectedAlertPresentException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.common.exceptions的用法示例。


在下文中一共展示了exceptions.UnexpectedAlertPresentException方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makeScreen

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import UnexpectedAlertPresentException [as 别名]
def makeScreen(name, url, driver):
	try:
		driver.get(url)
		screenshot = driver.save_screenshot(basename + '/' + str(name) + '.png')
		appendHTML(name, url)
	
		print('[-] Screenshooted: ' + url)
		return True
	except UnexpectedAlertPresentException as e:
		print('[!] Error: ' + str(e))
		err.append(url)
		return False
	except TimeoutException as t:
		print('[!] Timeout: ' + str(t))
		err.append(url)
		return False 
开发者ID:si9int,项目名称:ScreenShooter,代码行数:18,代码来源:exe.py

示例2: __wait_for_appearing

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import UnexpectedAlertPresentException [as 别名]
def __wait_for_appearing(self):

        t = 0
        while t < 120:
            t = t + 1

            try:
                elements = Browser.RunningBrowser.find_elements(self.by, self.value)
            except NoSuchElementException:
                logger.step_normal("Element [%s]: NoSuchElementException." % self.__name__)
                elements = []
                continue
            except UnexpectedAlertPresentException:
                logger.step_warning("Element [%s]: UnexpectedAlertPresentException." % self.__name__)

            if len(elements) == 0:
                time.sleep(0.5)
                logger.step_normal("Element [%s]: WaitForAppearing... Wait 1 second, By [%s]" % (self.__name__,
                                                                                                 self.value))
            else:
                logger.step_normal("Element [%s]: Found [%s] Element. Tried [%s] Times." % (self.__name__,
                                                                                            len(elements), t))
                break 
开发者ID:hw712,项目名称:knitter,代码行数:25,代码来源:webelement.py

示例3: __wait_for_disappearing

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import UnexpectedAlertPresentException [as 别名]
def __wait_for_disappearing(self):

        t = 0
        while t < 120:
            t = t + 1

            try:
                elements = Browser.RunningBrowser.find_elements(self.by, self.value)
            except NoSuchElementException:
                logger.step_normal("Element [%s]: NoSuchElementException." % self.__name__)
                elements = []
                continue
            except UnexpectedAlertPresentException:
                logger.step_warning("Element [%s]: UnexpectedAlertPresentException." % self.__name__)

            if len(elements) == 0:
                return True
            else:
                time.sleep(0.5)
                logger.step_normal("Element [%s]: WairForDisappearing... Found [%s] Element. Tried [%s] Times." %
                                   (self.__name__, len(elements), t))

        return False 
开发者ID:hw712,项目名称:knitter,代码行数:25,代码来源:webelement.py

示例4: test_click_with_open_alert_raises_exception

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import UnexpectedAlertPresentException [as 别名]
def test_click_with_open_alert_raises_exception(self):
		with self.assertRaises(UnexpectedAlertPresentException) as cm:
			click("OK")
		msg = self._get_unhandled_alert_exception_msg(cm.exception)
		self.assertEqual(
			self.UNEXPECTED_ALERT_PRESENT_EXCEPTION_MSG, msg
		) 
开发者ID:mherrmann,项目名称:selenium-python-helium,代码行数:9,代码来源:test_alert.py

示例5: test_press_with_open_alert_raises_exception

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import UnexpectedAlertPresentException [as 别名]
def test_press_with_open_alert_raises_exception(self):
		with self.assertRaises(UnexpectedAlertPresentException) as cm:
			press(ENTER)
		msg = self._get_unhandled_alert_exception_msg(cm.exception)
		self.assertEqual(
			self.UNEXPECTED_ALERT_PRESENT_EXCEPTION_MSG, msg
		) 
开发者ID:mherrmann,项目名称:selenium-python-helium,代码行数:9,代码来源:test_alert.py

示例6: _get_unhandled_alert_exception_msg

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import UnexpectedAlertPresentException [as 别名]
def _get_unhandled_alert_exception_msg(self, e):
		if selenium.__version__ == '2.43.0':
			# Selenium 2.43.0 has a regression where accessing the .msg field
			# of an UnexpectedAlertPresentException raises an AttributeError -
			# See: https://code.google.com/p/selenium/issues/detail?id=7886
			return e.args[0]
		else:
			return e.msg 
开发者ID:mherrmann,项目名称:selenium-python-helium,代码行数:10,代码来源:test_alert.py

示例7: test_write_into_label_raises_exception

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import UnexpectedAlertPresentException [as 别名]
def test_write_into_label_raises_exception(self):
		with self.assertRaises(UnexpectedAlertPresentException) as cm:
			write("3", into="Please enter a value")
		msg = self._get_unhandled_alert_exception_msg(cm.exception)
		self.assertEqual(
			self.UNEXPECTED_ALERT_PRESENT_EXCEPTION_MSG, msg
		) 
开发者ID:mherrmann,项目名称:selenium-python-helium,代码行数:9,代码来源:test_alert.py

示例8: test_write_into_text_field_raises_exception

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import UnexpectedAlertPresentException [as 别名]
def test_write_into_text_field_raises_exception(self):
		with self.assertRaises(UnexpectedAlertPresentException) as cm:
			write("4", into=TextField("Please enter a value"))
		msg = self._get_unhandled_alert_exception_msg(cm.exception)
		self.assertEqual(
			self.UNEXPECTED_ALERT_PRESENT_EXCEPTION_MSG, msg
		) 
开发者ID:mherrmann,项目名称:selenium-python-helium,代码行数:9,代码来源:test_alert.py

示例9: __wait

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import UnexpectedAlertPresentException [as 别名]
def __wait(self):
        t = 0
        while t < 300:
            t = t + 1

            try:
                elements = Browser.RunningBrowser.find_elements(self.by, self.value)
            except NoSuchElementException:
                logger.step_normal("Element [%s]: NoSuchElementException." % self.__name__)
                elements = []
            except UnexpectedAlertPresentException:
                logger.step_warning("Element [%s]: UnexpectedAlertPresentException." % self.__name__)

            if len(elements) == 0:
                time.sleep(1)
                logger.step_normal("Element [%s]: Wait 1 second, By [%s :: %s :: %s]" % (self.__name__,
                                                                                           self.by,
                                                                                           self.value,
                                                                                           self.index))
            else:
                if len(elements) > 1:
                    logger.step_normal("Element [%s]: There are [%s] Elements!" % (self.__name__, len(elements)))

                break

        if len(elements) < self.index + 1:
            logger.step_fail("Element [%s]: Element Index Issue! There are [%s] Elements! Index=[%s]" % (self.__name__,
                                                                                                         len(elements),
                                                                                                         self.index)) 
开发者ID:hw712,项目名称:knitter,代码行数:31,代码来源:webelement.py


注:本文中的selenium.common.exceptions.UnexpectedAlertPresentException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。