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


Python expected_conditions.visibility_of_element_located方法代碼示例

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


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

示例1: __login

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def __login(self):
        if self.debug: self.driver.save_screenshot(self.directory + r'01.png')
        txt_login = self.driver.find_element_by_id('ctl00_ContentPlaceHolder1_txtLogin')
        txt_login.clear()
        txt_login.send_keys(os.environ['CPF'])

        time.sleep(3.0)
        txt_senha = self.driver.find_element_by_id('ctl00_ContentPlaceHolder1_txtSenha')
        txt_senha.clear()
        txt_senha.send_keys(os.environ['SENHA_CEI'])
        time.sleep(3.0)

        if self.debug: self.driver.save_screenshot(self.directory + r'02.png')

        btn_logar = self.driver.find_element_by_id('ctl00_ContentPlaceHolder1_btnLogar')
        btn_logar.click()

        try:
            WebDriverWait(self.driver, 60).until(EC.visibility_of_element_located((By.ID, 'objGrafPosiInv')))
        except Exception as ex:
            raise Exception('Nao foi possivel logar no CEI. Possivelmente usuario/senha errada ou indisponibilidade do site')

        if self.debug: self.driver.save_screenshot(self.directory + r'03.png') 
開發者ID:guilhermecgs,項目名稱:ir,代碼行數:25,代碼來源:crawler_cei.py

示例2: __recupera_tipo_ticker

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def __recupera_tipo_ticker(self):
        WebDriverWait(CrawlerAdvfn.driver, 10).until(EC.visibility_of_element_located((By.ID, 'quoteElementPiece5')))
        tipo = CrawlerAdvfn.driver.find_element_by_id('quoteElementPiece5').text.lower()

        if tipo == 'futuro':
            return TipoTicker.FUTURO

        if tipo == 'opção':
            return TipoTicker.OPCAO

        if tipo == 'preferencial' or tipo == 'ordinária':
            return TipoTicker.ACAO

        if tipo == 'fundo':
            if self.__fundo_eh_fii():
                return TipoTicker.FII

            if self.__fundo_eh_etf():
                return TipoTicker.ETF

        return None 
開發者ID:guilhermecgs,項目名稱:ir,代碼行數:23,代碼來源:crawler_advfn.py

示例3: test05CreateNewProjectWithAllFiles

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def test05CreateNewProjectWithAllFiles(self):
        self.login()
        WebDriverWait(self.browser, 5).until(EC.visibility_of_element_located((By.XPATH, '//button[@title="upload data files"]')))

        self.browser.find_element_by_xpath('//button[@title="upload data files"]').click()
        WebDriverWait(self.browser, 5).until(EC.visibility_of_element_located((By.ID, 'uploadTitle')))
        self.browser.find_element_by_id('uploadTitle').send_keys('test_project_with_all_files')
        self.browser.find_element_by_id('uploadDescription').send_keys('description of test project')
        self.browser.find_element_by_id('treeFileSelect').send_keys(self.BASEPATH+'tree.txt')
        self.browser.find_element_by_id('fastaFileSelect').send_keys(self.BASEPATH+'fasta.fa')
        self.browser.find_element_by_id('dataFileSelect').send_keys(self.BASEPATH+'view_data.txt')
        self.browser.find_element_by_id('samplesOrderFileSelect').send_keys(self.BASEPATH+'samples-order.txt')
        self.browser.find_element_by_id('samplesInformationFileSelect').send_keys(self.BASEPATH+'samples-information.txt')
        self.browser.find_element_by_id('uploadFiles').click()
        WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.LINK_TEXT, 'test_project_with_all_files')))
        self.assertTrue(self.browser.find_element_by_link_text('test_project_with_all_files')) 
開發者ID:merenlab,項目名稱:anvio,代碼行數:18,代碼來源:run_server_tests.py

示例4: get_latest_wallpapers

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def get_latest_wallpapers():
    browser = webdriver.PhantomJS(PHANTOMJS_PATH, service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])
    today_date = time.strftime("%d+%b+%Y")  
    yesterday = datetime.now() - timedelta(days=1)
    yesterday_date = yesterday.strftime('%d+%b+%Y')
    first_page_url = 'http://www.espncricinfo.com/ci/content/image/?datefrom='+yesterday_date+'&dateupto='+today_date+';'
    browser.get(first_page_url)
    wait = WebDriverWait(browser, 10)
    wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "img-wrap")))
    time.sleep(2)
    # let's parse our html
    soup = BeautifulSoup(browser.page_source, "html.parser")
    images = soup.find_all('div', class_='picture')
    for image in images:
        url = "http://www.espncricinfo.com/" + image.find('a').get('href')
        print(url) 
開發者ID:DedSecInside,項目名稱:Awesome-Scripts,代碼行數:18,代碼來源:scrape_espncricinfo.py

示例5: find_element

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def find_element(browser, locator, locator_strategy=By.CSS_SELECTOR, except_on_timeout=True, visible=False, delay=CHECK_IF_EXISTS_TIMEOUT):
    if except_on_timeout:
        if visible:
            element = WebDriverWait(browser, delay).until(
                ec.visibility_of_element_located((locator_strategy, locator)))
        else:
            element = WebDriverWait(browser, delay).until(
                ec.presence_of_element_located((locator_strategy, locator)))
        return element
    else:
        try:
            if visible:
                element = WebDriverWait(browser, delay).until(
                    ec.visibility_of_element_located((locator_strategy, locator)))
            else:
                element = WebDriverWait(browser, delay).until(
                    ec.presence_of_element_located((locator_strategy, locator)))
            return element
        except TimeoutException as e:
            log.debug(e)
            log.debug("Check your {} locator: {}".format(locator_strategy, locator))
            # print the session_id and url in case the element is not found
            if browser is webdriver.Remote:
                # noinspection PyProtectedMember
                log.debug("In case you want to reuse session, the session_id and _url for current browser session are: {},{}".format(browser.session_id, browser.command_executor._url)) 
開發者ID:timelyart,項目名稱:Kairos,代碼行數:27,代碼來源:tv.py

示例6: wait_for_visible

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def wait_for_visible(self, selector='', **kwargs):
        '''
        Wait for an element to be visible.

        Parameters
        ----------
        selector: str
            A CSS selector to search for. This can be any valid CSS selector.

        kwargs:
            Passed on to _wait_for

        '''
        if selector.startswith('/'):
            by = By.XPATH
        else:
            by = By.CSS_SELECTOR
        self._wait_for(EC.visibility_of_element_located((by, selector)),
                       **kwargs) 
開發者ID:IntuitiveWebSolutions,項目名稱:PyWebRunner,代碼行數:21,代碼來源:WebRunner.py

示例7: login

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def login(self, uemail):
        self.open(reverse('accounts:login'))
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_username')))
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )
        self.selenium.find_element_by_id('id_username').send_keys(uemail)
        self.selenium.find_element_by_id('id_password').send_keys(boguspwd)
        self.selenium.find_element_by_id('submit-id-sign_in').click()
        # Wait for the user profile page
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, '//div[@id="workflow-index"]')
            )
        )

        self.assertIn('reate a workflow', self.selenium.page_source) 
開發者ID:abelardopardo,項目名稱:ontask_b,代碼行數:20,代碼來源:__init__.py

示例8: click_dropdown_option_and_wait

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def click_dropdown_option_and_wait(self, dd_xpath, option_name,
        wait_for=None):
        """
        Given a dropdown xpath, click to open and then click on the given option
        :param dd_xpath: xpath to locate the dropdown element (top level)
        :param option_name: name of the option in the dropdown to click
        :param wait_for: @id to wait for, or modal open if none.
        :return: Nothing
        """
        self.click_dropdown_option(dd_xpath, option_name)

        if wait_for:
            WebDriverWait(self.selenium, 10).until(
                EC.presence_of_element_located(
                    (By.ID, wait_for)
                )
            )
            WebDriverWait(self.selenium, 10).until_not(
                EC.visibility_of_element_located((By.ID, 'div-spinner'))
            )
        else:
            self.wait_for_modal_open() 
開發者ID:abelardopardo,項目名稱:ontask_b,代碼行數:24,代碼來源:__init__.py

示例9: access_workflow_from_home_page

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def access_workflow_from_home_page(self, wname):
        xpath = '//h5[contains(@class, "card-header") and ' \
                'normalize-space(text()) = "{0}"]'

        # Verify that this is the right page
        self.assertIn('New workflow', self.selenium.page_source)
        self.assertIn('Import workflow', self.selenium.page_source)

        WebDriverWait(self.selenium, 10).until(EC.element_to_be_clickable(
            (By.XPATH, xpath.format(wname))
        ))
        self.selenium.find_element_by_xpath(xpath.format(wname)).click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'action-index'))
        )
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        ) 
開發者ID:abelardopardo,項目名稱:ontask_b,代碼行數:20,代碼來源:__init__.py

示例10: findElement

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def findElement(parent, css_selector):
    """
    Menemukan element dengan CSS Selector.
    """

    try:
        elem = waitingResult(visibility_of_element_located, By.CSS_SELECTOR, css_selector)
        return elem
    except NoSuchElementException:
        return None 
開發者ID:brutemap-dev,項目名稱:brutemap,代碼行數:12,代碼來源:core.py

示例11: open_locust_homepage

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def open_locust_homepage(self):
        self.client.get("http://locust.io/")
        self.client.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, '//a[text()="Documentation"]')
            )
        ) 
開發者ID:nickboucart,項目名稱:realbrowserlocusts,代碼行數:9,代碼來源:locustfile.py

示例12: click_through_to_documentation

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def click_through_to_documentation(self):
        self.client\
            .find_element_by_xpath('//a[text()="Documentation"]').click()
        self.client.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, '//h1[text()="Locust Documentation"]')
            )
        ) 
開發者ID:nickboucart,項目名稱:realbrowserlocusts,代碼行數:10,代碼來源:locustfile.py

示例13: __recupera_preco_atual

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def __recupera_preco_atual(self):
        WebDriverWait(CrawlerAdvfn.driver, 10).until(EC.visibility_of_element_located((By.ID, 'quoteElementPiece10')))
        preco_atual = float(CrawlerAdvfn.driver.find_element_by_id('quoteElementPiece10').text
                            .replace('.', '').replace(',', '.'))
        return preco_atual 
開發者ID:guilhermecgs,項目名稱:ir,代碼行數:7,代碼來源:crawler_advfn.py

示例14: _wait_until_element_is_visible_by_locator

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def _wait_until_element_is_visible_by_locator(context, locator_tuple,
                                              timeout=TIMEOUT_IN_S):
    wait = WebDriverWait(context.browser, timeout)
    wait.until(EC.visibility_of_element_located(locator_tuple))
    return context.browser.find_element(locator_tuple[0], locator_tuple[1]) 
開發者ID:leapcode,項目名稱:bitmask-dev,代碼行數:7,代碼來源:common.py

示例15: wait_until_button_is_visible

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of_element_located [as 別名]
def wait_until_button_is_visible(context, title, timeout=TIMEOUT_IN_S):
    wait = WebDriverWait(context.browser, timeout)
    locator_tuple = (By.XPATH, ("//%s[contains(.,'%s')]" % ('button', title)))
    wait.until(EC.visibility_of_element_located(locator_tuple)) 
開發者ID:leapcode,項目名稱:bitmask-dev,代碼行數:6,代碼來源:common.py


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