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


Python WebDriverWait.find_elements_by_class_name方法代码示例

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


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

示例1: _setLevelCount

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_class_name [as 别名]
    def _setLevelCount(self, driver, value):
        levelSpinParent = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "imageContourLevelCount")))
        #Upper spin button
        levelSpinInput = levelSpinParent.find_element_by_xpath( ".//input" )
        currentValue = levelSpinInput.get_attribute("value")
        print "Current level ", currentValue
        diff = value - int(currentValue)
        print "Diff=",diff
        levelButs = levelSpinParent.find_elements_by_class_name( "qx-button")
        buttonCount = len( levelButs )
        print "Button count=",buttonCount
        buttonIndex = 0

        if diff < 0 :
            #Use the decrease button if both buttons are enabled
            if buttonCount > 1 :
                buttonIndex = 1
            #levelSpinButton = levelSpinParent.find_element_by_xpath( ".//div[1]")
            diff = diff * -1

        ActionChains( driver).move_to_element( levelButs[buttonIndex] )
        for i in range( diff ):
            ActionChains(driver).click( levelButs[buttonIndex] ).perform()
        newValue = levelSpinInput.get_attribute("value")
        self.assertEqual( newValue, str(value), "Level spin not correct")
开发者ID:Astroua,项目名称:CARTAvis,代码行数:27,代码来源:tContour.py

示例2: __navigate_to_location_rec

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_class_name [as 别名]
 def __navigate_to_location_rec(self, root, breadcrumbs):
     breadcrumb = breadcrumbs[0]
     if len(breadcrumbs) == 1:
         WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located((By.LINK_TEXT, breadcrumbs[0])))
         last_el = self.driver.find_element_by_link_text(breadcrumbs[0])
         last_el.click()
     else:
         folder = WebDriverWait(root, 20).until(
             my_visibility_of_elements((By.XPATH, "//div[@class='side_menu_folder']"), breadcrumb))
         expanded = len(folder.find_elements_by_class_name('expanded')) > 0
         if not expanded:
             folder.click()
         self.__navigate_to_location_rec(folder, breadcrumbs[1:])
开发者ID:da3m0n,项目名称:ctrguiautotest,代码行数:15,代码来源:utilsCopy.py

示例3: parse

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_class_name [as 别名]
	def parse(self,response):

		link=response.url
		browser=webdriver.Firefox()
		browser.implicitly_wait(HikvisionSpider.timeout)
		browser.set_page_load_timeout(HikvisionSpider.timeout)
		try:
			browser.get(link)
		except TimeoutException:
			pass
		
		element=WebDriverWait(browser,HikvisionSpider.timeout).until(EC.presence_of_element_located((By.CLASS_NAME,"doxx")))
		lines=element.find_elements_by_class_name("doxx2")
		items=Set()
		for l in lines:
			t=HikvisionSpider.trytimes
			while 1:
				try:
					did=l.find_element_by_xpath("a").get_attribute("name")
					nbrowser=webdriver.Firefox()
					nbrowser.set_page_load_timeout(HikvisionSpider.timeout)
					try:
						nbrowser.get(HikvisionSpider.ajaxlink+did)
					except TimeoutException:
						pass
					rawlink=nbrowser.find_element_by_xpath("//body").text
#			print rawlink
#			continue
					item=BasicItem()
					item["Firm"]="Hikvision"
					item["Info"]={}
					item["Link"]="http://download.hikvision.com/"+rawlink
					item["Rawlink"]=item["Link"]
					item["Filename"]=rawlink.rsplit("/",1).pop()
					item["Title"]=l.find_element_by_class_name("doxx4").text
					item["Descr"]=l.find_element_by_class_name("doxx10").text
				except Exception,e:
					nbrowser.quit()
					t-=1
					if t==0:
						logging.exception(e)
						break
				else:
					nbrowser.quit()
					items.add(item)
					break
开发者ID:kooksee,项目名称:firmSpyder,代码行数:48,代码来源:hikvisionSpider.py

示例4: __init__

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_class_name [as 别名]
class TheaterDetail:
    # Class to define elements of the theater detail page
    def __init__(self, driver):
        self.driver = driver

        # Often need to wait after TheaterCalendar object has caused a new page load
        # NOTE: _theaterMoviesListContainer is duplicated in class TheaterCalendar
        self._theaterMoviesListContainer = WebDriverWait(driver, Settings.seleniumWaitTime).until(
             EC.presence_of_element_located((By.CLASS_NAME, "movies-box")))

        self.theaterName = driver.find_element_by_class_name("inner-holder").find_element_by_tag_name("h1").text
        self.theaterMoviesList = self.get_movies_list()

    def get_movies_list(self):
        movieList = []
        # NOTE: movies is duplicated in class TheaterCalendar
        movies = self._theaterMoviesListContainer.find_elements_by_class_name("item")
        for movie in movies:
            movieList.append(MovieDetail(movie))
        return movieList
开发者ID:josephconlin,项目名称:CinemarkMoviesTests,代码行数:22,代码来源:TheaterDetailPage.py

示例5: WebDriverWait

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_class_name [as 别名]
user = driver.find_element_by_id("user")
user.send_keys(login)
password = driver.find_element_by_id("password")
password.send_keys(senha)
password.submit()


botao = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "server_select_list")))
driver.execute_script("return  Index.submit_login('server_br56');")
saque = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "manager_icon")))
saque.click()
farm_table =  WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "am_widget_Farm")))
uri = driver.current_url+"&Farm_page="

abas = len(farm_table.find_elements_by_class_name("paged-nav-item"))+1

inf=1
rec_farm=0
total_farm=0

while inf==1:
    doFarm.count = 0
    for i in range(0,abas):
        driver.get(uri+`i`)
        farm_table =  WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "am_widget_Farm")))
        if (len(farm_table.find_elements_by_id("bot_check_form"))>0) :
            exit()
        result = doFarm()
        if result is False:
            break
开发者ID:allanroscoche,项目名称:twbot,代码行数:32,代码来源:farm_win.py

示例6: MainMenuLinks

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_class_name [as 别名]
class MainMenuLinks(unittest.TestCase):
    def setUp(self):
        self.apps_url = "http://7themes.su/"
        self.driver = webdriver.Chrome(executable_path="/opt/chromedriver")
        self.driver.maximize_window()
        self.driver.get(self.apps_url)
        #this is the main <nav> block with all menu items
        self.menu = WebDriverWait (self.driver, 10).until(
            ec.visibility_of_element_located((By.TAG_NAME, 'nav')))
        #these are Themes, Scins, wallpapers and other main menu tabs
        self.tabs = self.menu.find_elements_by_class_name('uWithSubmenu')
        
        self.themes = self.tabs[0]
        self.themes_menu_links = self.tabs[0].find_elements_by_tag_name('a') #all links in Themes
        
        self.skins = self.tabs[1]
        self.skins_menu_links = self.tabs[1].find_elements_by_tag_name('a') #all links in Skins
        
        self.icons = self.tabs[2]
        self.icons_menu_links = self.tabs[2].find_elements_by_tag_name('a') #all links in Icons
        
        self.wallpapers = self.tabs[3]
        self.wallpapers_menu_links = self.tabs[3].find_elements_by_tag_name('a') #Wallpapers
        
        self.cursors = self.tabs[4]
        self.cursors_menu_links = self.tabs[4].find_elements_by_tag_name('a') #Cursors

        self.different = self.tabs[5]
        self.different_menu_links = self.tabs[5].find_elements_by_tag_name('a') #Different
       
        self.forum = self.driver.find_element_by_xpath('//nav/ul/li[7]/a/span') #Forum
        
        self.faq = self.driver.find_element_by_xpath('//nav/ul/li[8]/a/span') #FAQ

    def click_to_link(self, tab, tab_link):
        mouse_move_to_menu = ActionChains(self.driver)
        mouse_move_to_menu.move_to_element(tab)
        mouse_move_to_menu.move_to_element(tab_link)
        mouse_move_to_menu.click(tab_link)
        mouse_move_to_menu.perform()
        time.sleep(5)
        WebDriverWait (self.driver, 10).until(ec.title_is(self.driver.title))
        current_page_info = {}
        current_page_info['current_page_title'] = self.driver.title.encode('utf-8')
        current_page_info['current_url'] = self.driver.current_url
        return (current_page_info)

    def click_to_tab_link(self, tab_link):
        mouse_move_to_menu = ActionChains(self.driver)
        mouse_move_to_menu.move_to_element(tab_link)
        mouse_move_to_menu.click(tab_link)
        mouse_move_to_menu.perform()
        time.sleep(5)
        WebDriverWait (self.driver, 10).until(ec.title_is(self.driver.title))
        current_page_info = {}
        current_page_info['current_page_title'] = self.driver.title.encode('utf-8')
        current_page_info['current_url'] = self.driver.current_url
        return (current_page_info)
    
    #Tests menu tab Themes
    #@unittest.skip("test skipping")    
    def test_1_themes_0(self):
        ''' Top link in Themes menu'''
        self.title_page_must_be = 'Оформление ОС Windows 7, 8 и 10 - 7themes.su'
        self.url_must_be = 'http://7themes.su/'
        self.click = self.click_to_link(self.themes, self.themes_menu_links[0])
        self.assertIn(self.title_page_must_be, self.click['current_page_title'])
        self.assertIn(self.url_must_be, self.click['current_url'])
    
    #@unittest.skip("test skipping")
    def test_2_themes_1(self):
        ''' First link in Themes menu'''
        self.title_page_must_be = 'Темы для Windows 7 - скачать темы для рабочего стола'
        self.url_must_be = 'http://7themes.su/load/windows_7_themes/21'
        self.click = self.click_to_link(self.themes, self.themes_menu_links[1])
        self.assertIn(self.title_page_must_be, self.click['current_page_title'])
        self.assertIn(self.url_must_be, self.click['current_url'])
    
    #@unittest.skip("test skipping")
    def test_3_themes_2(self):
        ''' Second link in Themes menu '''
        self.title_page_must_be = 'Темы для Windows 8/8.1 - оформление интерфейса OС Windows 8'
        self.url_must_be = 'http://7themes.su/load/windows_8_themes/20'
        self.click = self.click_to_link(self.themes, self.themes_menu_links[2])
        self.assertIn(self.title_page_must_be, self.click['current_page_title'])
        self.assertIn(self.url_must_be, self.click['current_url'])       

    #@unittest.skip("test skipping")
    def test_4_themes_3(self):
        ''' Third link in Themes menu '''
        self.title_page_must_be = 'Темы для Windows 10 - оформление рабочего стола ОС Windows 10'
        self.url_must_be = 'http://7themes.su/load/windows_10_themes/32'
        self.click = self.click_to_link(self.themes, self.themes_menu_links[3])
        self.assertIn(self.title_page_must_be, self.click['current_page_title'])
        self.assertIn(self.url_must_be, self.click['current_url'])      

    #@unittest.skip("test skipping")
    def test_5_themes_4(self):
        ''' Fourth link in Themes menu '''
        self.title_page_must_be = 'Пакеты оформления для Windows 7'
#.........这里部分代码省略.........
开发者ID:dmytrobondarchuk,项目名称:7themes_tests,代码行数:103,代码来源:Test_Main_Menu_Links.py


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