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


Python exceptions.TimeoutException方法代码示例

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


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

示例1: wait_until_visible

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def wait_until_visible(self, timeout=None):
        """Search element and wait until it is visible

        :param timeout: max time to wait
        :returns: page element instance
        """
        try:
            self.utils.wait_until_element_visible(self, timeout)
        except TimeoutException as exception:
            parent_msg = " and parent locator '{}'".format(self.parent) if self.parent else ''
            msg = "Page element of type '%s' with locator %s%s not found or is not visible after %s seconds"
            timeout = timeout if timeout else self.utils.get_explicitly_wait()
            self.logger.error(msg, type(self).__name__, self.locator, parent_msg, timeout)
            exception.msg += "\n  {}".format(msg % (type(self).__name__, self.locator, parent_msg, timeout))
            raise exception
        return self 
开发者ID:Telefonica,项目名称:toolium,代码行数:18,代码来源:page_element.py

示例2: wait_until_not_visible

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def wait_until_not_visible(self, timeout=None):
        """Search element and wait until it is not visible

        :param timeout: max time to wait
        :returns: page element instance
        """
        try:
            self.utils.wait_until_element_not_visible(self, timeout)
        except TimeoutException as exception:
            parent_msg = " and parent locator '{}'".format(self.parent) if self.parent else ''
            msg = "Page element of type '%s' with locator %s%s is still visible after %s seconds"
            timeout = timeout if timeout else self.utils.get_explicitly_wait()
            self.logger.error(msg, type(self).__name__, self.locator, parent_msg, timeout)
            exception.msg += "\n  {}".format(msg % (type(self).__name__, self.locator, parent_msg, timeout))
            raise exception
        return self 
开发者ID:Telefonica,项目名称:toolium,代码行数:18,代码来源:page_element.py

示例3: wait_until_clickable

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def wait_until_clickable(self, timeout=None):
        """Search element and wait until it is clickable

        :param timeout: max time to wait
        :returns: page element instance
        """
        try:
            self.utils.wait_until_element_clickable(self, timeout)
        except TimeoutException as exception:
            parent_msg = " and parent locator '{}'".format(self.parent) if self.parent else ''
            msg = "Page element of type '%s' with locator %s%s not found or is not clickable after %s seconds"
            timeout = timeout if timeout else self.utils.get_explicitly_wait()
            self.logger.error(msg, type(self).__name__, self.locator, parent_msg, timeout)
            exception.msg += "\n  {}".format(msg % (type(self).__name__, self.locator, parent_msg, timeout))
            raise exception
        return self 
开发者ID:Telefonica,项目名称:toolium,代码行数:18,代码来源:page_element.py

示例4: wait_until_first_element_is_found

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def wait_until_first_element_is_found(self, elements, timeout=None):
        """Search list of elements and wait until one of them is found

        :param elements: list of PageElements or element locators as a tuple (locator_type, locator_value) to be found
                         sequentially
        :param timeout: max time to wait
        :returns: first element found
        :rtype: toolium.pageelements.PageElement or tuple
        :raises TimeoutException: If no element in the list is found after the timeout
        """
        try:
            return self._wait_until(self._expected_condition_find_first_element, elements, timeout)
        except TimeoutException as exception:
            msg = 'None of the page elements has been found after %s seconds'
            timeout = timeout if timeout else self.get_explicitly_wait()
            self.logger.error(msg, timeout)
            exception.msg += "\n  {}".format(msg % timeout)
            raise exception 
开发者ID:Telefonica,项目名称:toolium,代码行数:20,代码来源:driver_utils.py

示例5: makeScreen

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [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

示例6: wait_activity

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def wait_activity(self: T, activity: str, timeout: int, interval: int = 1) -> bool:
        """Wait for an activity: block until target activity presents or time out.

        This is an Android-only method.

        Args:
            activity: target activity
            timeout: max wait time, in seconds
            interval: sleep interval between retries, in seconds

        Returns:
            `True` if the target activity is shown
        """
        try:
            WebDriverWait(self, timeout, interval).until(
                lambda d: d.current_activity == activity)
            return True
        except TimeoutException:
            return False

    # pylint: disable=protected-access
    # noinspection PyProtectedMember 
开发者ID:appium,项目名称:python-client,代码行数:24,代码来源:activities.py

示例7: scan_webdriver

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def scan_webdriver(self):
        self.browser.get(self.entry_url)

        try:
            WebDriverWait(self.browser, 30).until(
                EC.presence_of_element_located((By.TAG_NAME, "body"))
            )
        except TimeoutException as e:
            messages.error(self.request, e)

        self.browser.delete_all_cookies()
        self.browser.add_cookie(self.wtm_cookie)
        self.browser.add_cookie(self.wtm_debug_cookie)
        self.browser.get(self.entry_url)

        for cookie in self.browser.get_cookies():
            self.process_webdriver_cookie(cookie)

        self.browser.quit() 
开发者ID:jberghoef,项目名称:wagtail-tag-manager,代码行数:21,代码来源:webdriver.py

示例8: sign_off

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def sign_off(self):
        """Submit questionnaire and finish.

        This uses Selenium to click the submit button on the questionnaire
        and return to the original window.
        """
        try:
            logger.info("Bot player signing off.")
            feedback = WebDriverWait(self.driver, 20).until(
                EC.presence_of_element_located((By.ID, "submit-questionnaire"))
            )
            self.complete_questionnaire()
            feedback.click()
            logger.info("Clicked submit questionnaire button.")
            self.driver.switch_to_window(self.driver.window_handles[0])
            self.driver.set_window_size(1024, 768)
            logger.info("Switched back to initial window.")
            return True
        except TimeoutException:
            logger.error("Error during experiment sign off.")
            return False 
开发者ID:Dallinger,项目名称:Dallinger,代码行数:23,代码来源:bots.py

示例9: send_message

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def send_message(self, name, message):
        message = self.emojify(message)  # this will emojify all the emoji which is present as the text in string
        search = self.browser.find_element_by_css_selector("._3FRCZ")
        search.send_keys(name+Keys.ENTER)  # we will send the name to the input key box
        try:
            send_msg = WebDriverWait(self.browser, self.timeout).until(EC.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[4]/div/footer/div[1]/div[2]/div/div[2]")))
            messages = message.split("\n")
            for msg in messages:
                send_msg.send_keys(msg)
                send_msg.send_keys(Keys.SHIFT+Keys.ENTER)
            send_msg.send_keys(Keys.ENTER)
            return True
        except TimeoutException:
            raise TimeoutError("Your request has been timed out! Try overriding timeout!")
        except NoSuchElementException:
            return False
        except Exception:
            return False

    # This method will count the no of participants for the group name provided 
开发者ID:VISWESWARAN1998,项目名称:Simple-Yet-Hackable-WhatsApp-api,代码行数:23,代码来源:whatsapp.py

示例10: get_last_seen

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def get_last_seen(self, name, timeout=10):
        search = self.browser.find_element_by_css_selector("._3FRCZ")
        search.send_keys(name+Keys.ENTER)  # we will send the name to the input key box
        last_seen_css_selector = "._315-i"
        start_time = dt.datetime.now()
        try:
            WebDriverWait(self.browser,self.timeout).until(EC.presence_of_element_located(
                (By.CSS_SELECTOR, last_seen_css_selector)))
            while True:
                last_seen = self.browser.find_element_by_css_selector(last_seen_css_selector).text
                if last_seen and "click here" not in last_seen:
                    return last_seen
                end_time = dt.datetime.now()
                elapsed_time = (end_time-start_time).seconds
                if elapsed_time > 10:
                    return "None"
        except TimeoutException:
            raise TimeoutError("Your request has been timed out! Try overriding timeout!")
        except NoSuchElementException:
            return "None"
        except Exception:
            return "None"

    # This method does not care about anything, it sends message to the currently active chat
    # you can use this method to recursively send the messages to the same person 
开发者ID:VISWESWARAN1998,项目名称:Simple-Yet-Hackable-WhatsApp-api,代码行数:27,代码来源:whatsapp.py

示例11: load_initial

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def load_initial(self, company):
        url = 'https://www.linkedin.com/company/{}'.format(company)

        self.driver.get(url)
        try:
            myElem = WebDriverWait(self.driver, self.timeout).until(AnyEC(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, '.organization-outlet')),
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, '.error-container'))
            ))
        except TimeoutException as e:
            raise ValueError(
                """Took too long to load company.  Common problems/solutions:
                1. Invalid LI_AT value: ensure that yours is correct (they
                   update frequently)
                2. Slow Internet: increase the timeout parameter in the Scraper constructor""")
        try:
            self.driver.find_element_by_css_selector('.organization-outlet')
        except:
            raise ValueError(
                'Company Unavailable: Company link does not match any companies on LinkedIn') 
开发者ID:austinoboyle,项目名称:scrape-linkedin-selenium,代码行数:24,代码来源:CompanyScraper.py

示例12: get_first_connections

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def get_first_connections(self):
        try:
            see_connections_link = WebDriverWait(self.driver, self.timeout).until(EC.presence_of_element_located((
                By.CSS_SELECTOR,
                '.pv-top-card-v2-section__link--connections'
            )))
        except TimeoutException as e:
            print("""Took too long to load connections link. This usually indicates you were trying to
scrape the connections of someone you aren't connected to.""")
            return []

        see_connections_link.click()
        try:
            self.configure_connection_type()
        except TimeoutException:
            return []
        all_conns = [] 
开发者ID:austinoboyle,项目名称:scrape-linkedin-selenium,代码行数:19,代码来源:ConnectionScraper.py

示例13: _make

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def _make(self, debug):
        options = webdriver.ChromeOptions()
        options.add_argument("--headless")
        options.binary_location = settings.SELENIUM_CUSTOM_CHROME_PATH

        browser = webdriver.Chrome(settings.SELENIUM_CHROMEDRIVER_PATH, options=options)
        browser.get('file://' + os.path.abspath(os.path.join(self.dir, 'input.html')))
        self.log = self.get_log(browser)

        try:
            WebDriverWait(browser, 15).until(EC.presence_of_element_located((By.CLASS_NAME, 'math-loaded')))
        except TimeoutException:
            logger.error('PDF math rendering timed out')
            self.log = self.get_log(browser) + '\nPDF math rendering timed out'
            return

        response = browser.execute_cdp_cmd('Page.printToPDF', self.template)
        self.log = self.get_log(browser)
        if not response:
            return

        with open(os.path.abspath(os.path.join(self.dir, 'output.pdf')), 'wb') as f:
            f.write(base64.b64decode(response['data']))

        self.success = True 
开发者ID:DMOJ,项目名称:online-judge,代码行数:27,代码来源:pdf_problems.py

示例14: wait_until_element_present

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def wait_until_element_present(self, element, timeout=None):
        """Search element and wait until it is found

        :param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
        :param timeout: max time to wait
        :returns: the web element if it is present
        :rtype: selenium.webdriver.remote.webelement.WebElement or appium.webdriver.webelement.WebElement
        :raises TimeoutException: If the element is not found after the timeout
        """
        return self._wait_until(self._expected_condition_find_element, element, timeout) 
开发者ID:Telefonica,项目名称:toolium,代码行数:12,代码来源:driver_utils.py

示例15: wait_until_element_visible

# 需要导入模块: from selenium.common import exceptions [as 别名]
# 或者: from selenium.common.exceptions import TimeoutException [as 别名]
def wait_until_element_visible(self, element, timeout=None):
        """Search element and wait until it is visible

        :param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
        :param timeout: max time to wait
        :returns: the web element if it is visible
        :rtype: selenium.webdriver.remote.webelement.WebElement or appium.webdriver.webelement.WebElement
        :raises TimeoutException: If the element is still not visible after the timeout
        """
        return self._wait_until(self._expected_condition_find_element_visible, element, timeout) 
开发者ID:Telefonica,项目名称:toolium,代码行数:12,代码来源:driver_utils.py


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