Python loop for getting list of elements on few pages -
in application have table users,but table can have more 1 page users. want list users in pages selenium webdriver python. need algorithm gonna count users in first page click on second page count there , until pages done, , return entire list. have idea don't know how realize that, below:
def users(driver): list_users = [] list_users in range(n): #selector click on second page num = num + 1 #getting users 1 page driver.find_elements_by_css_selector(".even .odd") #click on second page until pages exist driver.find_elements_by_link_text("%s" % num) until nosuchelementexception return list_users
i know it's not close working algorithm tried explain want
assuming need total number of people , have logged in...
people = driver.find_element_by_xpath('//* [@id="frmlist_ohrmlistcomponent"]/div[1]/ul/li[1]').text print people
yields "1-50 of 53" websites index seen here
that tells total amount of people in list
then total use
print people.split()[2]
which give value of 53
-------------edit-----------------------
to users loop through tags , pages
from math import ceil pages = ceil(float(people.split()[2])/50) users = [] p in range(1,int(pages)+1): driver.execute_script('javascript:submitpage(%s)' % p) #change page in range(1,51): try: user = driver.find_element_by_xpath('//* [@id="resulttable"]/tbody/tr[%s]/td[2]' % i) #change tag____^ users.append(user.text) except: break print users
Comments
Post a Comment