Python selenium.webdriver.common.keys.Keys 模块,ARROW_DOWN 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用selenium.webdriver.common.keys.Keys.ARROW_DOWN

项目:kitaab_bot    作者:rajdeep1008    | 项目源码 | 文件源码
def download_book(url, name):
    chromedriver = '/home/rajdeep1008/Desktop/chromedriver'
    os.environ["webdriver.chrome.driver"] = chromedriver
    driver = webdriver.Chrome(chromedriver)
    driver.get(url)
    link = driver.find_element_by_link_text(name)
    actionChains = ActionChains(driver)
    actionChains.context_click(link)
    actionChains.send_keys(Keys.ARROW_DOWN)
    actionChains.send_keys(Keys.ARROW_DOWN)
    actionChains.send_keys(Keys.ARROW_DOWN)
    actionChains.send_keys(Keys.ARROW_DOWN)
    actionChains.send_keys(Keys.RETURN)
    actionChains.perform()

    while True:
        if not os.path.isfile('/home/rajdeep1008/Downloads/' + name + '.pdf'):
            time.sleep(5)
        else:
            break
    driver.quit()

# download_book('http://it-ebooks.info/book/6719/', 'Android Studio Game Development')
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def enterAndSelectFromDropdown(self, by, value, text, message = None, nth = 1, \
        dropdownBy = None, dropdownValue = None):
        element = self.assertElementPresent(by, value, message = message)
        if not element: self.onFail(by, value, message, "Not found")
        element = self.sendKeys(by, value, text)

        if dropdownBy:
            self.assertElementPresent(dropdownBy, dropdownValue, message)
        description = "{0}-th from {1} dropdown".format(nth, self.describeElement(by, value))
        self.log("Find " + description)
        for i in range(1, nth+1):
            element = self.sendKeys(by, value, Keys.ARROW_DOWN)

        element = self.sendKeys(by, value, Keys.ENTER, message = "Select " + description)
        return element
项目:ugc.aggregator    作者:Dreamcatcher-GIS    | 项目源码 | 文件源码
def scroll_and_click_by_partial_link_text(self, text, from_bottom=False):
        if from_bottom:
            # ????
            self.driver.find_element_by_tag_name("body").send_keys(Keys.END)
            key = Keys.ARROW_UP
        else:
            # ????
            self.driver.find_element_by_tag_name("body").send_keys(Keys.HOME)
            key = Keys.ARROW_DOWN
        x = 0
        while 1:
            x += 1
            if x%500 == 0:
                self.driver.refresh()
                time.sleep(2)
                if from_bottom:
                    self.driver.find_element_by_tag_name("body").send_keys(Keys.END)
                else:
                    self.driver.find_element_by_tag_name("body").send_keys(Keys.HOME)
            if x == 1501:
                print u"????????" + self.driver.current_url
                break
            self.driver.find_element_by_tag_name("body").send_keys(key)
            try:
                self.driver.find_element_by_partial_link_text(text).click()
                break
            except:
                continue
项目:ugc.aggregator    作者:Dreamcatcher-GIS    | 项目源码 | 文件源码
def scroll_and_click_by_xpath(self, text, from_bottom=False, refresh_if_failed=True, sleep_time=0):
        if from_bottom:
            # ????
            self.driver.find_element_by_tag_name("body").send_keys(Keys.END)
            key = Keys.ARROW_UP
        else:
            # ????
            self.driver.find_element_by_tag_name("body").send_keys(Keys.HOME)
            key = Keys.ARROW_DOWN
        time.sleep(sleep_time)
        x = 0
        while 1:
            x += 1
            if x%500 == 0:
                # ??????
                if refresh_if_failed:
                    self.driver.refresh()
                time.sleep(sleep_time)
                if from_bottom:
                    self.driver.find_element_by_tag_name("body").send_keys(Keys.END)

                else:
                    self.driver.find_element_by_tag_name("body").send_keys(Keys.HOME)
                time.sleep(sleep_time)
            if x == 1501:
                print u"????????" + self.driver.current_url
                break
            self.driver.find_element_by_tag_name("body").send_keys(key)
            try:
                self.driver.find_element_by_xpath(text).click()
                break
            except:
                # print text
                continue
项目:wechat-spider    作者:bowenpay    | 项目源码 | 文件源码
def visit_wechat_index(self, wechatid):
        """ ???????????id??????? """
        browser = self.browser
        browser.get("http://weixin.sogou.com/")
        print browser.title
        element_querybox = browser.find_element_by_name('query')
        element_querybox.send_keys(wechatid, Keys.ARROW_DOWN)
        element_search_btn = browser.find_element_by_xpath("//input[@value='????']")
        element_search_btn.click()
        time.sleep(3)
        print browser.title
项目:wechat-spider    作者:bowenpay    | 项目源码 | 文件源码
def visit_wechat_index_keyword(self, word):
        """ ?????????????????? """
        browser = self.browser
        browser.get("http://weixin.sogou.com/")
        print browser.title
        element_querybox = browser.find_element_by_name('query')
        element_querybox.send_keys(word, Keys.ARROW_DOWN)
        element_search_btn = browser.find_element_by_xpath("//input[@value='???']")
        element_search_btn.click()
        time.sleep(3)
        print browser.title