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


Python WebDriverWait.find_element_by_tag_name方法代码示例

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


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

示例1: sendMessageToSelected

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
def sendMessageToSelected(message):
  element = WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.TAG_NAME,'swx-textarea')))
  element = element.find_element_by_tag_name("textarea")
  element.click()
  element.clear()
  element.send_keys(message)
  element.send_keys(Keys.ENTER)
开发者ID:SriramKeerthi,项目名称:pySkypeBot,代码行数:9,代码来源:pyskypebot.py

示例2: logoutDrlv

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
def logoutDrlv(browser):
    try:
        logout = WebDriverWait(browser, 80).until(EC.presence_of_element_located((By.ID , 'logout')))
        logoutHref = logout.find_element_by_tag_name("a")   # logout
        print logoutHref.text
        logoutHref.click()
    except Exception, e:
        print e
        print "Nevar izlogoties"
开发者ID:jajanka,项目名称:drlv-automata,代码行数:11,代码来源:drlv.py

示例3: writeMsg

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
def writeMsg(browser, msg):
    try:
        textareaDiv = WebDriverWait(browser, 80).until(EC.presence_of_element_located((By.CLASS_NAME , "textareaAutoHeight")))
        textarea = textareaDiv.find_element_by_tag_name('textarea')
        textarea.send_keys(msg)
        return True
    except Exception, e:
        print e
        print "Nevar ierakstit vestules tekstu"
        return False
开发者ID:jajanka,项目名称:drlv-automata,代码行数:12,代码来源:drlv.py

示例4: get_client_credentials_from_page

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
def get_client_credentials_from_page(browser):
    success_message_element = WebDriverWait(browser, 10).until(
        EC.visibility_of_element_located((By.CLASS_NAME, "alert-success")))
    list = success_message_element.find_element_by_tag_name("ul")

    client_credentials = {}
    for element in list.find_elements_by_tag_name("li"):
        try:
            key, value = element.text.split(": ", 1)
            client_credentials[key] = value
        except ValueError:
            pass  # ignore row not containing colon-separated key-value pair

    return client_credentials
开发者ID:rebeckag,项目名称:openid-course_teaching-material,代码行数:16,代码来源:test_static_client_registration.py

示例5: test_scheduled_visit_field_lead_time_validation

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
    def test_scheduled_visit_field_lead_time_validation(self):
        date_text = format(localtime(now()) + timedelta(hours=1), '%m/%d/%Y %I:%M %p')
        submit_button = self.selenium.find_element_by_id('submit-id-submit')
        visit_schedule_field = self.selenium.find_element_by_name('visit_schedule')

        ActionChains(self.selenium).send_keys_to_element(visit_schedule_field, date_text).click(submit_button).perform()

        try:
            visit_schedule_error = WebDriverWait(self.selenium, 10).until(
                EC.presence_of_element_located((By.ID, 'error_1_id_visit_schedule'))
            )

            self.assertEqual(visit_schedule_error.find_element_by_tag_name('strong').text,
                             'Kindly give use at least 24 hrs. lead time to schedule your appointment.')
        except TimeoutException as e:
            self.fail('Unable to Execute Test Properly')
开发者ID:asabalon,项目名称:cs260,代码行数:18,代码来源:tests_add_appointment.py

示例6: test_visit_description_field_format_constraint

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
    def test_visit_description_field_format_constraint(self):
        sample_text = 'Text with ; character'
        submit_button = self.selenium.find_element_by_id('submit-id-submit')
        visit_description_field = self.selenium.find_element_by_id('id_visit_description')

        ActionChains(self.selenium).send_keys_to_element(visit_description_field, sample_text).click(
            submit_button).perform()

        try:
            visit_description_error = WebDriverWait(self.selenium, 10).until(
                EC.presence_of_element_located((By.ID, 'error_1_id_visit_description'))
            )

            self.assertEqual(visit_description_error.find_element_by_tag_name('strong').text,
                             'No Special Characters are allowed in this field')
        except TimeoutException as e:
            self.fail('Unable to Execute Test Properly')
开发者ID:asabalon,项目名称:cs260,代码行数:19,代码来源:tests_add_appointment.py

示例7: Article

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
class Article():
    """Rozetka Store or Manufacturer Page"""
    def __init__(self, arg):
        self.arg = arg

    def FindInRozetka(self):
        """Find an article at rozetka store"""
        self.URL = 'http://rozetka.com.ua/'
        #self.driver = webdriver.Chrome(executable_path="C:\seleniumchromwdriver\chromedriver.exe")
        if os.name == 'nt':
            self.driver = webdriver.Chrome(executable_path="C:\seleniumchromwdriver\chromedriver.exe")
        else:
            self.driver = webdriver.Chrome(executable_path="/opt/chromedriver")
        self.driver.get(self.URL)
        

        self.finder_field = WebDriverWait (self.driver, 10).until(
            ec.visibility_of_element_located((By.NAME, 'text')))
    

        self.finder_field.send_keys(self.arg)

        self.finder_button = WebDriverWait (self.driver, 10).until(
            ec.visibility_of_element_located((By.NAME, 'search-button')))


        self.finder_button.click()

        self.found_list_of_items = WebDriverWait (self.driver, 10).until(
            ec.visibility_of_element_located((By.CLASS_NAME, 'g-i-list-title')))

        self.first_item = self.found_list_of_items.find_element_by_tag_name('a')

        self.first_item.click()

        self.characteristics = WebDriverWait (self.driver, 10).until(
            ec.visibility_of_element_located((By.CLASS_NAME, 'detail-description'))).text

        print (self.characteristics)
开发者ID:dmytrobondarchuk,项目名称:parser,代码行数:41,代码来源:poltergeist.py

示例8: isEveryOneFinish

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

        elem_projecs_2 = WebDriverWait(self.driver, 10).until(lambda driver : driver.find_element_by_link_text("Projects"))
        elem_projecs_2.click()
        time.sleep(5)

#        myprojects = {"1": "fbug",
#                      "2": "casacore",
#                      "3": "google-web-toolkit",
#                      "4": "flylinkdc", "5": "miranda",
#                       "6": "native_client", "7": "xe-core",
#                      "8": "geogebra",
#                      "9": "openmobster",
#                      "10": "tortoisesvn",
#                      "11": "cacheless_false_test","12": "cacheless_true_test",
#                      "13": "cacheless_false_test1","14": "cacheless_true_test1"}
#
        myprojects = {"1": "Project1",
                      "2": "Project2",
                      "3": "Project3",
                      "4": "Project4",
                      "5": "Project5",
                      "6": "Project6",
                      "7": "Project7",
                      "8": "Project8",
                      "9": "Project9",
                      "10": "Project10"}
        #for loop  check every project finish
        #table_projects = WebDriverWait(self.driver,15).until(lamdba my_driver : my_driver.find_element_by_xpath('//*[@id="projectListing"]/table[2]/tbody/tr[2]/td/table/tbody/tr[3]/td/table/tbody'))
        table_projects = self.driver.find_element_by_xpath('//*[@id="projectListing"]/table[2]/tbody/tr[2]/td/table/tbody/tr[3]/td/table/tbody')
        proj_step_ok='/gfx/OK.gif'
        proj_step_error='gfx/ERROR.gif'
        finish_counter=0
        global error_counter
        global error_projects
        error_projects=[]
        error_counter=0
        print "====================================================="
        for num in range(1,11):
            print "num is " + str(num)
            try:
               link = table_projects.find_element_by_link_text(myprojects[str(num)])
               href = link.get_attribute('href')
            except:
               try:
                   print "1 catche every one expcetion"
                   table_projects = self.driver.find_element_by_xpath('//*[@id="projectListing"]/table[2]/tbody/tr[2]/td/table/tbody/tr[3]/td/table/tbody')
                   link = table_projects.find_element_by_link_text(myprojects[str(num)])
                   href = link.get_attribute('href')
               except:
                   print "2 catche every one expcetion"
                   table_projects = self.driver.find_element_by_xpath('//*[@id="projectListing"]/table[2]/tbody/tr[2]/td/table/tbody/tr[3]/td/table/tbody')
                   link = table_projects.find_element_by_link_text(myprojects[str(num)])
                   href = link.get_attribute('href')
            projects_id = href.split('=')[1]
            print "project id is "+ projects_id
            xpath_table_icon = "statusContent_" + projects_id
            print "xpth table icon is "+ xpath_table_icon
            #every_proj_status = self.driver.find_element_by_id(xpath_table_icon)
            try:
               print "1.catch imag exception"
               every_proj_status = WebDriverWait(self.driver,20).until(lambda driver_1 : driver_1.find_element_by_id(xpath_table_icon))
               per_proj_status = every_proj_status.find_element_by_tag_name('img')
               str_status = per_proj_status.get_attribute('src')
            except:
               try:
                  print "2.catch imag exception"
                  every_proj_status = WebDriverWait(self.driver,20).until(lambda driver_1 : driver_1.find_element_by_id(xpath_table_icon))
                  per_proj_status = every_proj_status.find_element_by_tag_name('img')
                  str_status = per_proj_status.get_attribute('src')
               except:
                    try:
                        print "3.catch imag exception"
                        every_proj_status = WebDriverWait(self.driver,20).until(lambda driver_1 : driver_1.find_element_by_id(xpath_table_icon))
                        per_proj_status = every_proj_status.find_element_by_tag_name('img')
                        str_status = per_proj_status.get_attribute('src')
                    except:
                        every_proj_status = WebDriverWait(self.driver,20).until(lambda driver_1 : driver_1.find_element_by_id(xpath_table_icon))
                        per_proj_status = every_proj_status.find_element_by_tag_name('img')
                        str_status = per_proj_status.get_attribute('src')

            print "str_status is "+ str(str_status)
            is_finish = re.search(proj_step_ok,str(str_status))
            is_error = re.search(proj_step_error,str(str_status))
            if is_finish :
                finish_counter = finish_counter + 1
            elif is_error:
                error_counter = error_counter + 1
                print "error project is %s" % myprojects[str(num)]
                error_projects.append(myprojects[str(num)])
        sum=finish_counter + error_counter
        f = open('./log/error_projects.log','a+')
        f.write("In cycle "+ self.param + "\n".join(error_projects))
        f.close()
        return sum
开发者ID:AmyOrchid188,项目名称:Knowledge,代码行数:97,代码来源:krugle_junhui.py

示例9: select_search_results_element

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
def select_search_results_element(driver):
    search_results = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.ID, "search_results")))
    search_results_body = search_results.find_element_by_tag_name('tbody')
    return search_results_body
开发者ID:datamade,项目名称:lobbying_federal_domestic,代码行数:6,代码来源:scraping_house_clerk_site.py

示例10: topPBatters

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
def topPBatters(**kwargs):
    """
    kwargs -> listOfTuples
        p: int | the number of players to return 
        activeDate: datetime.date | today's date 
        filt: Dict | possible entries...
                    -> "minERA": float | exclude all players who are facing a 
                       starting pitcher with an ERA below this number


    Produces a TupleOfTuples where each tuple is of format:
        (firstName, lastName, teamAbbreviations)
        for a player that is among the top P players by batting average
        this season and is starting today. If "minERA" is in kwargs[filter], 
        then only includes players who are facing a starting pitcher with
        ERA >= minERA
    """
    print "topPBatters. P, minERA: {}, {}".format(kwargs['p'], kwargs['filt']['minERA'])
    import logging 

    from pyvirtualdisplay import Display
    from datetime import datetime
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC

    from config import ROOT

    ## type check
    assert type(kwargs['p'] == int)
    if 'filt' in kwargs.keys():
        assert (type(kwargs['filt']) == dict)
        if 'minERA' in kwargs['filt'].keys():
            assert type(kwargs['filt']['minERA'] == float)

    ## Sanity check
    if kwargs['activeDate'] != datetime.today().date():
        today = datetime.today().date()
        print "\nWARNING: As you are selecting on a future date," + \
           " the top batters w.r.t batting average will be from TODAY" + \
           " {} and we will filter out the players who".format(today) + \
           " aren't starting or are facing a pitcher with too high an ERA" + \
           " using the given date {}".format(kwargs['activeDate'])

    ## start a display if necessary, and start the browser
    if ROOT == '/home/faiyamrahman/programming/Python/beatthestreakBots':
        print "--> Starting display to get batters"
        display = Display(visible=0, size=(1024, 768))
        display.start()
    else:
        display = None
    browser = webdriver.Chrome()

    # Create a logger so that we don't get blasted with unnecessary info
    # on every error in a test suite. Instead, we only get high priority shit
    seleniumLogger = logging.getLogger('selenium.webdriver.remote.remote_connection')
    seleniumLogger.setLevel(logging.WARNING) 

    players = []
    # if anything happens and we exit prematurely, quit the browser, then reraise
    try:
        ## Get top P players from espn website
            # get the batting page from espn
        browser.get('http://espn.go.com/mlb/stats/batting')
        for passThrough in ('firstTime', 'secondTime'):

            ## If it's greater than 40 players, click the next page
            if passThrough == 'firstTime':
                indexOffset = 0
            elif passThrough == 'secondTime':
                if kwargs['p'] <= 40: # we don't need a second passthrough!
                    break
                indexOffset = 40
                browser.find_element_by_partial_link_text('NEXT').click()

            # Table of players
            table = WebDriverWait(browser, 10).until(
                EC.presence_of_element_located((By.TAG_NAME, 'table')))
            tablebody = table.find_element_by_tag_name('tbody')
            oddRows = tablebody.find_elements_by_class_name('oddrow')
            evenRows = tablebody.find_elements_by_class_name('evenrow')
            allRows = []

            for rowPair in zip( oddRows, evenRows ):
                allRows.extend( rowPair )
                # extract player information from each row
            for index, row in enumerate( allRows ):
                    # row cells 
                cells = row.find_elements_by_tag_name('td')
                    # cell[1].text is player's first and last name
                nextPlayer = [ str(name) for name in cells[1].text.split() ]
                    # cell[2].text is player's 3DigitTeamAbbrev
                team = str( cells[2].text.lower() )
                if team == 'chw': # convert for chicago white sox, to comply with boy.pt
                    team = 'cws'
                if "/" in team:   # if a player was traded, team is oldTeam/newTeam
                    team = team.split('/')[-1]
                    print "CHANGED {} {}'s TEAM!".format(nextPlayer[0], nextPlayer[1])
                nextPlayer.append( team )
#.........这里部分代码省略.........
开发者ID:frahman5,项目名称:beatthestreakBots,代码行数:103,代码来源:selectfunctions.py

示例11: ActionChains

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

示例12: get_username

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_tag_name [as 别名]
 def get_username(self, player):
     trainer_elem = WebDriverWait(self.root, 2).until(
         EC.presence_of_element_located((By.XPATH, "//div[@class='{}']/div[@class='trainer']".format(PLAYER_ELEMS[player.value])))
     )
     return trainer_elem.find_element_by_tag_name('strong').text
开发者ID:A-Malone,项目名称:pokemon-showdown-ai-api,代码行数:7,代码来源:showdown_battle.py


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