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


Python WebDriverWait.find_element_by_class_name方法代码示例

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


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

示例1: test_qunit

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_class_name [as 别名]
    def test_qunit(self):
        """Load the QUnit tests and check for failures."""

        self.browser.get(self.live_server_url + settings.STATIC_URL + 'index.html')
        results = WebDriverWait(self.browser, 5).until(
            expected_conditions.visibility_of_element_located((By.ID, 'qunit-testresult')))
        total = int(results.find_element_by_class_name('total').text)
        failed = int(results.find_element_by_class_name('failed').text)
        self.assertTrue(total and not failed, results.text)
开发者ID:mlavin,项目名称:fileapi,代码行数:11,代码来源:test_qunit.py

示例2: test_jqueryplugin_with_qunit

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_class_name [as 别名]
 def test_jqueryplugin_with_qunit(self):
     url = "%s%s" % (self.live_server_url, reverse('qunit-tests'))
     self.browser.implicitly_wait(1)
     self.browser.get(url)
     results = WebDriverWait(self.browser, 5).until(
         expected_conditions.visibility_of_element_located(
             (By.ID, 'qunit-testresult')))
     self.browser.save_screenshot('/Users/danirus/screenshot.png')
     total = int(results.find_element_by_class_name('total').text)
     failed = int(results.find_element_by_class_name('failed').text)
     self.assertTrue(total and not failed, results.text)
开发者ID:danirus,项目名称:django-contactme,代码行数:13,代码来源:test_jqueryplugin.py

示例3: test_file_delete

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_class_name [as 别名]
    def test_file_delete(self):
        """Delete uploaded file."""

        _, test_file = tempfile.mkstemp(dir=self.temp_dir)
        self.login(self.username, self.password)
        element = WebDriverWait(self.browser, 5).until(
                expected_conditions.presence_of_element_located((By.CLASS_NAME, 'file')))
        element.find_element_by_class_name('delete').click()
        self.browser.implicitly_wait(1)
        with self.assertRaises(NoSuchElementException):
            self.browser.find_element_by_class_name('file')
        self.assertFalse(os.path.exists(test_file))
开发者ID:mlavin,项目名称:fileapi,代码行数:14,代码来源:test_functional.py

示例4: get_user

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_class_name [as 别名]
    def get_user(self):
        upload_url = self.base_upload_url.format(self.domain)
        previous_user = self.saved_data.get('user')
        user = None

        while user is None:
            t = get_input(r'^(y|n|)$', '\n\nIs username "{}" (y/n)? '.format(previous_user))
            if t == 'n':
                user = get_input(self.valid_user, '\n\nEnter new user: ')
            else:
                user = previous_user
            print('\n\nValidating user...\n')

            self.driver.get(upload_url.format(quote(user)))
            main_area = WebDriverWait(self.driver, self.timeout).until(
                lambda x:
                    self.check_enabled(
                        x.find_element_by_class_name('mainpart')
                        .find_elements_by_tag_name('td')[0]
                    )
            )

            try:
                error_text = main_area.find_element_by_class_name('errorpage').text
                if 'by {}'.format(user) in error_text or 'by {}'.format(quote(user)) in error_text:
                    t = get_input(r'^(y|n)$', '\n\nUser has no uploads, try another? (y/n) ')
                    if t == 'y':
                        user = None
                        continue
                    else:
                        self.driver.quit()
                        input('\n\nPress enter to quit...')
                        sys.exit()
                else:
                    t = get_input(r'^(y|n)$', '\n\nUnregistered user, try another (y/n)? ')
                    if t == 'y':
                        user = None
                        continue
                    else:
                        self.driver.quit()
                        input('\n\nPress enter to quit...')
                        sys.exit()
            except SystemExit:
                sys.exit()
            except NoSuchElementException:
                pass

        if user != previous_user:
            self.saved_data['user'] = user
            self.update_saved_data()
        self.user = user
开发者ID:footypoof,项目名称:katutil,代码行数:53,代码来源:katutil.py

示例5: test_has_date_and_time_picker_widget

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_class_name [as 别名]
    def test_has_date_and_time_picker_widget(self):
        datetime_picker_icon = self.selenium.find_element_by_class_name('glyphicon-calendar')

        ActionChains(self.selenium).click(datetime_picker_icon).perform()

        try:
            datetime_picker_widget = WebDriverWait(self.selenium, 10).until(
                EC.presence_of_element_located((By.CLASS_NAME, 'bootstrap-datetimepicker-widget'))
            )
            active_day = datetime_picker_widget.find_element_by_class_name('active')

            ActionChains(self.selenium).click(active_day).perform()

            selected_datetime = self.selenium.find_element_by_id('id_visit_schedule').get_attribute('value')
            self.assertTrue(datetime_picker_widget.is_displayed())
            self.assertEqual(time.strftime('%m/%d/%Y %I: %p'),
                             time.strftime('%m/%d/%Y %I: %p', time.strptime(selected_datetime, '%m/%d/%Y %I:%M %p')))
        except TimeoutException as e:
            self.fail('Unable to Execute Test Properly')
开发者ID:asabalon,项目名称:cs260,代码行数:21,代码来源:tests_add_appointment.py

示例6: WebDriverWait

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_class_name [as 别名]
        buttonid = button.get_attribute("id")
        if buttonid.startswith("NYU_CLS_DERIVED_TERM"):
            internalid = buttonid.split("$")[1]
            internalIDs.append(internalid)
            outdict[subject][internalid] = {}
            # these 'buttonids' are actually used for each subject thing
            # so will be very useful

    # Get course name
    for ident in internalIDs:
        coursetable = WebDriverWait(driver, timeout).until(
            EC.presence_of_element_located((By.ID, "win0divNYU_CLS_DERIVED_HTMLAREA$" + ident))
        )
        fulldesc = None
        try:
            desc = coursetable.find_element_by_class_name("courseDescription")
            courseid = desc.get_attribute("id").split("_")[1]  # to find the css id for long desc.
            coursetable.find_element_by_css_selector("a").click()
            longdesc = WebDriverWait(driver, timeout).until(
                EC.presence_of_element_located((By.ID, "fullDescription_" + courseid))
            )
            fulldesc = longdesc.text
        except selenium.common.exceptions.NoSuchElementException:
            fulldesc = coursetable.find_element_by_css_selector("p").text
        outdict[subject][ident]["desc"] = fulldesc
        outdict[subject][ident]["header"] = coursetable.find_element_by_css_selector("b").text

    # Get expanded table
    for ident in internalIDs:
        button = driver.find_element_by_id("NYU_CLS_DERIVED_TERM$" + ident)
        button.click()
开发者ID:Skyyrunner,项目名称:JeevesCoursePlanner,代码行数:33,代码来源:albertscraper.py

示例7: ActionChains

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_class_name [as 别名]
            hover = ActionChains(browser).move_to_element(arrow)
            hover.perform()
            sleep(4)
        hover = ActionChains(browser).move_to_element(movie_link)
        hover.perform()
    except Exception, e:
        print e
        hover = ActionChains(browser).move_to_element(arrow)
        hover.perform()
        sleep(5)
        move_off_arrow = ActionChains(browser).move_by_offset(-450, -130)
        move_off_arrow.perform()
        hover = ActionChains(browser).move_to_element(movie_link)
        hover.perform()
    try:
        movie_info = WebDriverWait(browser, 10).until(
            EC.element_to_be_clickable((By.ID, 'BobMovie')))
        title = movie_info.find_element_by_class_name('title').text
        link = movie_info.find_element_by_class_name(
            'mdpLink').get_attribute('href')
        desc = movie_info.find_element_by_class_name(
            'bobMovieContent').text.split('\n')[0]
        cast = movie_info.find_element_by_tag_name('dd').text
        movie_dict[title] = {'link': link, 'title': title,
                             'desc': desc, 'cast': cast}
    except:
        print "taking too long!"
    scroll_off = ActionChains(browser).move_by_offset(30, -130)
    scroll_off.perform()
    sleep(2)
开发者ID:ANDRESVA,项目名称:python-web-scraping-tutorial,代码行数:32,代码来源:scrape_netflix.py

示例8: WebDriverWait

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_class_name [as 别名]
#coding=utf-8

'''
随机测试
打开连接
http://sports.qq.com/seriea/
打印国米板块右侧所有的新闻标题和内容
'''
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

dr = webdriver.Firefox()
dr.get('http://sports.qq.com/seriea')
inter = WebDriverWait(dr, 10).until(lambda driver: dr.find_element_by_id('inter'))
hot_list = inter.find_element_by_class_name('hot_list')
links = hot_list.find_elements_by_tag_name('a')

sub = webdriver.Firefox()

for link in links:
    print link.get_attribute('href')
    print link.text
    print '#'*64
    sub.get(link.get_attribute('href'))

    try:
        mainpage = sub.find_element_by_id('Cnt-Main-Article-QQ')
        print mainpage
        contents = mainpage.find_elements_by_tag_name('p')
        for content in contents:
            print content.text
开发者ID:roytest001,项目名称:PythonHomework,代码行数:33,代码来源:qqtest.py

示例9: test_suggestions

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_class_name [as 别名]
 def test_suggestions(self):
     # Creamos el WebElement Search Field
     search_field = self.driver.find_element_by_id("query")
     search_field.send_keys("tele")
     suggestions = WebDriverWait(self.driver, 10).until(expected_conditions.visibility_of_element_located((By.ID, "ac-popover-2")))
     suggestions.find_element_by_class_name("ac-autocomplete-item").click()
开发者ID:TestingEnEsp,项目名称:IntroTestingAutomatizado,代码行数:8,代码来源:07_explicit_wait.py


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