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


Python expected_conditions.element_to_be_clickable方法代码示例

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


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

示例1: index_page

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def index_page(page):
    try:
        print('正在爬取第: %s 页' % page)
        wait.until(
            EC.presence_of_element_located((By.ID, "dt_1")))
        # 判断是否是第1页,如果大于1就输入跳转,否则等待加载完成。
        if page > 1:
            # 确定页数输入框
            input = wait.until(EC.presence_of_element_located(
                (By.XPATH, '//*[@id="PageContgopage"]')))
            input.click()
            input.clear()
            input.send_keys(page)
            submit = wait.until(EC.element_to_be_clickable(
                (By.CSS_SELECTOR, '#PageCont > a.btn_link')))
            submit.click()
            time.sleep(2)
        # 确认成功跳转到输入框中的指定页
        wait.until(EC.text_to_be_present_in_element(
            (By.CSS_SELECTOR, '#PageCont > span.at'), str(page)))
    except Exception:
        return None 
开发者ID:makcyun,项目名称:eastmoney_spider,代码行数:24,代码来源:eastmoney_crawler.py

示例2: access_workflow_from_home_page

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [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

示例3: loadmap

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def loadmap(self):
        '''
        loadmap()
        Creates a browser object and loads the webpage.
        It sets up the map to the proper zoom level.

        Returns the browser on success, None on fail.
        '''
        browser = webdriver.PhantomJS(desired_capabilities={'phantomjs.page.settings.resourceTimeout': '20000'})
        browser.set_window_size(abovetustin_image_width, abovetustin_image_height)

        print("getting web page {}".format(self.url))
        browser.set_page_load_timeout(15)
        browser.get(self.url)

        # Need to wait for the page to load
        timeout = g_request_timeout
        print ("waiting for page to load...")
        wait = WebDriverWait(browser, timeout)
        element = wait.until(EC.element_to_be_clickable((By.CLASS_NAME,'vrsMenu')))
        self.browser = browser 
开发者ID:kevinabrandon,项目名称:AboveTustin,代码行数:23,代码来源:screenshot.py

示例4: crack

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def crack(self):
        true_image = self.get_true_image()
        x_offset = self.analysis(true_image)
        print(x_offset)

        track = self.get_track(x_offset)
        knob_element = WebDriverWait(self.driver, 50).until(
            EC.element_to_be_clickable((By.XPATH, r'/html/body/div[2]/div[2]/div[6]/div/div[1]/div[2]/div[2]')))
        self.move_to_gap(knob_element, track)

        # fn = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'result0.png')
        # fn1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'result1.png')
        # time.sleep(0.02)
        # screen_shot = self.driver.save_screenshot(fn)
        # time.sleep(2)
        # screen_shot = self.driver.save_screenshot(fn1) 
开发者ID:ForgQi,项目名称:bilibiliupload,代码行数:18,代码来源:__init__.py

示例5: participate

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def participate(self):
        random.seed(self.worker_id)
        chatbot = random.choice(self.PERSONALITIES)
        WebDriverWait(self.driver, 10).until(
            EC.element_to_be_clickable((By.ID, "send-message"))
        )
        logger.info("Entering participate method")
        start = time.time()
        while (time.time() - start) < self.TOTAL_CHAT_TIME:

            self.wait_to_send_message()
            history = self.get_chat_history()
            logger.info("History: %s" % history)
            if history and history[-1]:
                logger.info("Responding to: %s" % history[-1])
                output = chatbot.respond(history[-1])
            else:
                logger.info("Using random greeting.")
                output = random.choice(self.GREETINGS)
            logger.info("Output: %s" % output)
            self.send_message(output)

        self.leave_chat() 
开发者ID:Dallinger,项目名称:Dallinger,代码行数:25,代码来源:bots.py

示例6: wait_until_clickable

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def wait_until_clickable(self, driver, elem_id, by=By.ID, timeout=10):
        """
        Wait for the modal to be shown.

        :param driver: Selenium driver instance
        :type driver: selenium.webdriver.remote.webdriver.WebDriver
        :param elem_id: element ID
        :type elem_id: str
        :param by: What method to use to find the element. This must be one of
          the strings which are values of
          :py:class:`selenium.webdriver.common.by.By` attributes.
        :type by: str
        :param timeout: timeout in seconds
        :type timeout: int
        """
        WebDriverWait(driver, timeout).until(
            EC.element_to_be_clickable((by, elem_id))
        ) 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:20,代码来源:acceptance_helpers.py

示例7: getNextPicture

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def getNextPicture(self):
        """
        Get the next picture to the given picture.
        """
        try:
            next = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.ID, INFOS['next'])))
            try:
                self.driver.execute_script("document.getElementById('" + INFOS['next'] + "').focus();")
            except:
                pass
            finally:
                next.click()
        except:
            try:
                next = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, INFOS['next3'])))
                next.click()
            except:
                pass 
开发者ID:bmenendez,项目名称:20up,代码行数:20,代码来源:tntapi.py

示例8: login

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def login(self):
        """login to linkedin then wait 3 seconds for page to load"""
        # Enter login credentials
        WebDriverWait(self.driver, 120).until(
            EC.element_to_be_clickable(
                (By.ID, "session_key-login")
            )
        )
        elem = self.driver.find_element_by_id("session_key-login")
        elem.send_keys(self.username)
        elem = self.driver.find_element_by_id("session_password-login")
        elem.send_keys(self.password)
        # Enter credentials with Keys.RETURN
        elem.send_keys(Keys.RETURN)
        # Wait a few seconds for the page to load
        time.sleep(3) 
开发者ID:kirkhunter,项目名称:linkedin-jobs-scraper,代码行数:18,代码来源:client.py

示例9: login

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def login(self):
        # 获取到登录按钮后点击
        login_btn = self.wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/e4g")))
        login_btn.click()
        # 获取使用微信号登录按钮
        change_login_btn = self.wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/cou")))
        change_login_btn.click()
        # 获取输入账号元素并输入
        account = self.wait.until(EC.presence_of_element_located((By.XPATH, '//*[@resource-id="com.tencent.mm:id/cos"]/android.widget.EditText')))
        account.send_keys("xxxxxxxx")
        # 获取密码元素并输入
        password = self.wait.until(EC.presence_of_element_located((By.XPATH,  '//*[@resource-id="com.tencent.mm:id/cot"]/android.widget.EditText')))
        password.send_keys("xxxxxx")
        # 登录
        login = self.wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/cov")))
        login.click()
        # 点击去掉通讯录提示框
        no_btn = self.wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/az9")))
        no_btn.click()
        print('登录成功...') 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:22,代码来源:wechat_moment.py

示例10: find_xiaoshuaib

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def find_xiaoshuaib(self):
        # 获取到搜索按钮后点击
        search_btn = self.wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/iq")))
        # 等搜索建立索引再点击
        time.sleep(10)
        search_btn.click()
        # 获取搜索框并输入
        search_input = self.wait.until(EC.presence_of_element_located((By.ID, "com.tencent.mm:id/kh")))
        search_input.send_keys("wistbean")
        print('搜索小帅b...')
        # 点击头像进入
        xiaoshuaib_btn = self.wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/py")))
        xiaoshuaib_btn.click()
        # 点击右上角...进入
        menu_btn = self.wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/jy")))
        menu_btn.click()
        # 再点击头像
        icon_btn = self.wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/e0c")))
        icon_btn.click()
        # 点击朋友圈
        moment_btn = self.wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/d86")))
        moment_btn.click()
        print('进入朋友圈...') 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:25,代码来源:wechat_moment.py

示例11: wait_for_clickable

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def wait_for_clickable(self, selector='', **kwargs):
        '''
        Wait for an element to be clickable.

        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.element_to_be_clickable((by, selector)), **kwargs) 
开发者ID:IntuitiveWebSolutions,项目名称:PyWebRunner,代码行数:20,代码来源:WebRunner.py

示例12: login

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def login(config):
    input_email = config['glob_username']
    input_pw = config['glob_password']
    log.info("Login with account email: " + input_email)
    driver.get('https://www.ebay-kleinanzeigen.de/m-einloggen.html')

    WebDriverWait(driver, 6).until(EC.element_to_be_clickable((By.ID, 'gdpr-banner-accept'))).click()

    text_area = WebDriverWait(driver, 1).until(EC.presence_of_element_located((By.ID, 'login-email')))
    text_area.send_keys(input_email)
    fake_wait(200)

    text_area = driver.find_element_by_id('login-password')
    text_area.send_keys(input_pw)
    fake_wait(200)

    submit_button = driver.find_element_by_id('login-submit')
    submit_button.click() 
开发者ID:donwayo,项目名称:ebayKleinanzeigen,代码行数:20,代码来源:kleinanzeigen.py

示例13: click_dropdown_option_by_number

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def click_dropdown_option_by_number(self, dd_xpath, option_num):
        """Click the nth option in a dropdown menu.

        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_num: position of the option in the dropdown to click
        :return: Nothing
        """
        self.selenium.find_element_by_xpath(dd_xpath).click()
        WebDriverWait(self.selenium, 10).until(EC.element_to_be_clickable(
            (By.XPATH,
             dd_xpath + '/..//*[{0}]'.format(option_num))
        ))
        self.selenium.find_element_by_xpath(
            dd_xpath + '/..//*[{0}]'.format(option_num)
        ).click() 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:19,代码来源:__init__.py

示例14: go_to_table

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def go_to_table(self):
        # Click in the top menu
        self.selenium.find_element_by_id('ontask-base-table').click()
        # Wait for the Full View to be clickable
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable(
                (By.LINK_TEXT, 'Full view')
            )
        )
        # Click on the full view element
        self.selenium.find_element_by_link_text('Full view').click()
        # Wait for page to refresh
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'table-content'))
        )
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )
        element = self.selenium.find_element_by_id('table-data')
        if element:
            # The table is present!
            self.wait_for_datatable('table-data_previous')

        self.assertIn('CSV Download', self.selenium.page_source) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:26,代码来源:__init__.py

示例15: go_to_workflow_operations

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import element_to_be_clickable [as 别名]
def go_to_workflow_operations(self):
        # Goto the details page
        self.selenium.find_element_by_id('ontask-base-settings').click()
        WebDriverWait(self.selenium, 10).until(EC.element_to_be_clickable(
            (By.XPATH,
             self.class_and_text_xpath.format('a',
                 'dropdown-item',
                 'Workflow operations'))
        ))
        self.selenium.find_element_by_id('ontask-base-workflow').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'workflow-detail'))
        )
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )
        self.assertIn('js-workflow-clone', self.selenium.page_source) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:19,代码来源:__init__.py


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