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


Python WebDriverWait.find_elements_by_tag_name方法代码示例

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


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

示例1: test_sprawdzVat

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
	def test_sprawdzVat(self):
		driver = self.driver
		driver.switch_to_window(driver.window_handles[1])  
		without_tax = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_class_name("without_tax")).text
		without_tax_f = float(without_tax.replace("," , "."))
		all_taxes = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_class_name("tax"))
		
		#----------------dict with zip :)))  pythonic way:))))  z dala od JAVA!!!!---------------------
		all_taxes_list = list(tax.text for tax in all_taxes.find_elements_by_tag_name("option"))
		global dict_withTax
		dict_withTax	= {}

		for tax in all_taxes.find_elements_by_tag_name("option"):
			print "petla dla: " + tax.text
			if tax.text in ("-" , "zw"):
				with_tax = without_tax_f
			else:
				tax_f =float(tax.text.replace("," , ".")) 
				with_tax = without_tax_f + (tax_f * without_tax_f)/100
			
			dict_withTax[tax.text] = with_tax
			Select(driver.find_element_by_name('elements[vat][]')).select_by_visible_text(tax.text)
			with_tax_naF = float(driver.find_element_by_class_name("with_tax").text.replace(",", "."))
			self.assertEqual(with_tax, with_tax_naF)
			
		print dict_withTax
开发者ID:mindagony,项目名称:Printmanager,代码行数:28,代码来源:F3.py

示例2: test_naGenF

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
	def test_naGenF(self):
		driver = self.driver
		driver.switch_to_window(driver.window_handles[1])  
		print "test_naGenF"
		
		all_taxes = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_class_name("tax"))
		all_taxes_list = list(tax.text for tax in all_taxes.find_elements_by_tag_name("option"))
		print all_taxes_list
		
		global dict_withTaxOnG
		dict_withTaxOnG= {}
		#-------------------------generowanie faktury----------------------
		def generujF():
			
			driver.find_element_by_id("save_elements").click()
			driver.find_element_by_name("submit").click()
			return
		
			
		for tax in all_taxes_list:
			driver.switch_to_window(driver.window_handles[1])
			self.driver.implicitly_wait(3)
			taxOnF = Select(driver.find_element_by_name('elements[vat][]')).select_by_visible_text(tax)
			generujF()
			driver.switch_to_window(driver.window_handles[-1])
			with_tax_naGenF= WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(".//*[@id='pageContainer1']/xhtml:div[2]/xhtml:div[47]")).text
			dict_withTaxOnG[tax] = float(with_tax_naGenF.replace(",", "."))

		print dict_withTaxOnG
		print dict_withTax
		self.assertEqual(dict_withTax, dict_withTaxOnG)
开发者ID:mindagony,项目名称:Printmanager,代码行数:33,代码来源:F3.py

示例3: check_cart

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
def check_cart():
    s = driver.find_element_by_name('commit')
    s.click()
    l1 = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "cart")))
    l2 = l1.find_elements_by_tag_name('a')
    l3 = l2[0]
    l3.click()
    
    try:
        s = WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((By.CLASS_NAME, "cart-description")))
        driver.save_screenshot("cart.png")
        flag2 = True
    except:
        print "Can't load into the cart page"
        return False
    
    if flag2:
        print "You are Going to buy:"
        print s.text
        s1 = driver.find_element_by_id('cart-footer')
        s2 = s1.find_elements_by_tag_name('a')
        for i in s2:
            if i.text == "checkout now":
                i.click()
                return True
        driver.save_screenshot("checkout.png")
        return False
开发者ID:hx364,项目名称:Supreme-Monitor,代码行数:30,代码来源:supreme_v1.py

示例4: get_checkboxes_list

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
 def get_checkboxes_list(self, xpath, tag_name):
     try:
         ul = WebDriverWait(self.browser, 10).until(
     EC.presence_of_element_located((By.XPATH, xpath))    )
         return ul.find_elements_by_tag_name(tag_name)  
     except UnboundLocalError, expr:
         print "Element can't be found: ", expr
开发者ID:katerinashch,项目名称:my_tests,代码行数:9,代码来源:base_page.py

示例5: test_sprawdzVat

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
	def test_sprawdzVat(self):
		driver = self.driver
		driver.switch_to_window(driver.window_handles[1])  
		without_tax = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_class_name("without_tax")).text
		without_tax_f = float(without_tax.replace("," , "."))
		all_taxes = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_class_name("tax"))
		for tax in all_taxes.find_elements_by_tag_name("option"):
			print "petla dla: " + tax.text
			if tax.text in ("-" , "zw"):
				print tax.text
				print without_tax_f
				with_tax = without_tax_f
			else:
				tax_f =float(tax.text.replace("," , ".")) 
				print tax_f
				with_tax = without_tax_f + (tax_f * without_tax_f)/100
			
			print with_tax
			
			
			Select(driver.find_element_by_name('elements[vat][]')).select_by_visible_text(tax.text)
			# save_elementsBtn = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id("save_elements"))
			
			# save_elementsBtn.click()
			with_tax_naF = float(driver.find_element_by_class_name("with_tax").text.replace(",", "."))
			self.assertEqual(with_tax, with_tax_naF)
开发者ID:mindagony,项目名称:Printmanager,代码行数:28,代码来源:F2d.py

示例6: test_user_interface_teacher

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
    def test_user_interface_teacher(self):
        teacher_username, teacher_password = 'teacher1', 'password'
        self.teacher = self.create_teacher(username=teacher_username,
                                           password=teacher_password)
        self.browser_login_teacher(username=teacher_username,
                                   password=teacher_password,
                                   facility_name=self.teacher.facility.name)
        self.browse_to(self.distributed_data_export_url)

        facility_select = WebDriverWait(self.browser, 30).until(EC.presence_of_element_located((By.ID, "facility-name")))
        self.assertFalse(facility_select.is_enabled(), "UI error")

        for option in facility_select.find_elements_by_tag_name('option'):
            if option.text == self.teacher.facility.name:
                self.assertTrue(option.is_selected(), "Invalid Facility Selected")
                break

        # Check that group is enabled now
        group_select = WebDriverWait(self.browser, 30).until(EC.presence_of_element_located((By.ID, "group-name")))
        WebDriverWait(self.browser, 5).until(lambda *_: group_select.is_enabled())

        # Click and make sure something happens
        # note: not actually clicking the download since selenium cannot handle file save dialogs
        export = self.browser.find_element_by_id("export-button")
        self.assertTrue(export.is_enabled(), "UI error")
开发者ID:arceduardvincent,项目名称:ka-lite,代码行数:27,代码来源:control_panel.py

示例7: test_sprawdzVat

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
	def test_sprawdzVat(self):
		driver = self.driver
		driver.switch_to_window(driver.window_handles[1])  
		without_tax = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_class_name("without_tax")).text
		without_tax_f = float(without_tax.replace("," , "."))
		all_taxes = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_class_name("tax"))
		for tax in all_taxes.find_elements_by_tag_name("option"):
			driver.switch_to_window(driver.window_handles[1])
			print "petla dla: " + tax.text
			if tax.text in ("-" , "zw"):
				print tax.text
				print without_tax_f
				with_tax = without_tax_f
			else:
				tax_f =float(tax.text.replace("," , ".")) 
				print tax_f
				with_tax = without_tax_f + (tax_f * without_tax_f)/100
			
			print with_tax
			
			
			Select(driver.find_element_by_name('elements[vat][]')).select_by_visible_text(tax.text)
			with_tax_naF = float(driver.find_element_by_class_name("with_tax").text.replace(",", "."))
			self.assertEqual(with_tax, with_tax_naF)
			
			#-------------------------generowanie faktury----------------------
			driver.find_element_by_id("save_elements").click()
			driver.find_element_by_name("submit").click()
			driver.switch_to_window(driver.window_handles[2])
			with_tax_naGenF= WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(".//*[@id='pageContainer1']/xhtml:div[2]/xhtml:div[47]")).text
			self.assertEqual(with_tax, with_tax_naGenF)
			print  with_tax_naGenF, with_tax
开发者ID:mindagony,项目名称:Printmanager,代码行数:34,代码来源:F2.py

示例8: selectPlugin

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
 def selectPlugin(self, expectedPluginName):
    select = WebDriverWait(self.__newPluginModalWebElement, 10).until(Condition.visibility_of_element_located((By.ID, "pluginTypeList")))
    for option in select.find_elements_by_tag_name('option'):
       if option.text == expectedPluginName:
          return option
    print "selectPlugin : Nothing to select, ", expectedPluginName, " not found"
    assert False
开发者ID:Yadoms,项目名称:yadoms,代码行数:9,代码来源:__init__.py

示例9: search_wiki

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
def search_wiki(name):
    txt = ''
    if name == '':
        return {'text': '', 'gender': ''}
    newurl = 'http://en.wikipedia.org/wiki/Main_Page'
    mydriver.get(newurl)
    search_form = mydriver.find_element_by_id('searchInput')
    search_form.send_keys(name)
    search_form.send_keys(Keys.RETURN)
    try:
        parentElement = WebDriverWait(mydriver, 10).until(
            EC.presence_of_element_located((By.ID,"mw-content-text"))
    )
    except TimeoutException:
        print 'wiki timeout!'
        return ''    
    elementList = parentElement.find_elements_by_tag_name("p")
    for element in elementList:
        txt = txt + ' ' + element.text 
    if txt.count(' he ')+txt.count(' his ') > txt.count(' she ')+txt.count(' her '):
        g = 'M'
    else:
        g = 'F'
    print txt
    return {'text': txt, 'gender':g}
开发者ID:prathinavelu,项目名称:kojak,代码行数:27,代码来源:author_gender_predictor.py

示例10: selectWidget

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
 def selectWidget(self, expectedWidgetName):
    widgetList = WebDriverWait(self.__newWidgetModalWebElement, 10).until(Condition.visibility_of_element_located((By.ID, "ul-add-widget")))
    for item in widgetList.find_elements_by_tag_name('button'):
       if item.get_attribute('widget-type') == expectedWidgetName:
          return item
    print "selectWidget : Nothing to select, ", expectedWidgetName, " not found"
    assert False
开发者ID:Yadoms,项目名称:yadoms,代码行数:9,代码来源:__init__.py

示例11: check_for_rows_in_list_table

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
    def check_for_rows_in_list_table(self, *needles):
        table = WebDriverWait(self.browser, 4)\
            .until(EC.element_to_be_clickable((By.ID, 'id_list_table')))

        table_rows = table.find_elements_by_tag_name('tr')
        row_texts = {row.text for row in table_rows}
        needles = set(needles)
        self.assertEquals(row_texts & needles, needles)
开发者ID:yeahframeoff,项目名称:tdd-tutor,代码行数:10,代码来源:base.py

示例12: closeMsgSentModal

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
def closeMsgSentModal(browser):
    try:
        bttnCloseDiv = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.CLASS_NAME , "InfoBoxContentWrap")))
        bttnOpenClose = bttnCloseDiv.find_elements_by_tag_name("button") # close sent msg success modal
        print bttnOpenClose[1].text
        bttnOpenClose[1].click();
        return True
    except Exception, e:
        print e
        print "Nevar aizvert modal pec nosutitas vestules"
        return False
开发者ID:jajanka,项目名称:drlv-automata,代码行数:13,代码来源:drlv.py

示例13: SocailButtons

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
class SocailButtons(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 block with all menu items
        self.block_with_top_social_buttons = WebDriverWait (self.driver, 10).until(
            ec.visibility_of_element_located((By.CLASS_NAME, 'top-social')))
        self.top_social_buttons = self.block_with_top_social_buttons.find_elements_by_tag_name('a')
   
        #these are Twitter, Vk, G+ and RSS buttons
        self.twitter = self.top_social_buttons[0]
        self.vk = self.top_social_buttons[1]
        self.gplus = self.top_social_buttons[2]
        self.rss = self.top_social_buttons[3]

    def click_to_social_button(self, socal_button):
        mouse_move_to_social_button = ActionChains(self.driver)
        mouse_move_to_social_button.move_to_element(socal_button)
        mouse_move_to_social_button.click(socal_button)
        mouse_move_to_social_button.perform()
        time.sleep(5)
        
        WebDriverWait (self.driver, 10).until(ec.title_is(self.driver.title))
        time.sleep(5)
        
        current_page_title = self.driver.title.encode('utf-8')
        current_url = self.driver.current_url

        print ("----------------")
        print (current_page_title)
        print (current_url)


        return (current_page_title, current_url)
    
    
    def test_twitter_social_button(self):
        ''' Tests Twitter social button'''
        self.title_page_must_be = ''
        self.url_must_be = 'https://twitter.com/7themes_su'
        
        self.click = self.click_to_social_button(self.twitter)
        
        #self.assertIn(self.title_page_must_be, self.click[0])
        #self.assertIn(self.url_must_be, self.click[1])


    def tearDown(self):
        self.driver.close()
开发者ID:dmytrobondarchuk,项目名称:7themes_tests,代码行数:55,代码来源:Test_social_buttons.py

示例14: pick_size

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
def pick_size(size):
    #size: Small, Medium, Large, XLarge
    size_component = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "size")))
    size_list = size_component.find_elements_by_tag_name('option')
    flag = False
    for i in size_list:
        if i.get_attribute("text") == size:
            print "Found the %r size" %size
            i.click()
            return True
    if not flag:
        print "%r size sold out" %size
        return False
开发者ID:hx364,项目名称:Supreme-Monitor,代码行数:15,代码来源:supreme_v1.py

示例15: __get__

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_elements_by_tag_name [as 别名]
 def __get__(self, obj, owner):
     try:
         driver = obj.driver
     except AttributeError:
         return
     element = WebDriverWait(driver, 100).until(
         lambda driver: driver.find_element_by_name(self.locator))
     element = driver.find_element_by_name(self.locator)
     element_value = element.get_attribute("value")
     all_options = element.find_elements_by_tag_name("option")
     for options in all_options:
         if options.get_attribute("value") == element_value:
             return str(options.text)
开发者ID:Forrestjohnston,项目名称:pitracker,代码行数:15,代码来源:element.py


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