當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。