def click_machine_name(name='computer_1'):
"""点击机器---按照机器名称
:param name: 机器名列表 [必填参数]
:ip:必填参数
:return: 无返回 ,错误直接异常退出
"""
find_element_by_css_selector('div[class="common-table-body"]')
find_element_by_tag_name_tmp('tbody')
tr_num = find_elements_by_tag_name_tmp('tr')
print('all tr is :'.format(tr_num))
for i in range(tr_num):
#print('i is :',i)
choose_element_from_elements(i)
data_str = text()
#print (data_str) #test-PC 172.24.83.102 0 0 2021-06-18
data_list = data_str.split()
print(data_list)
if name in data_list[0]:
#print(data_list)
find_element_by_tag_name_tmp('span')
click()
time.sleep(6)
def click_machine_ip(ip, name='computer_1'):
"""点击机器---按照机器ip
:param name: 机器名列表 [必填参数]
:ip:必填参数
:return: 无返回 ,错误直接异常退出
"""
find_element_by_css_selector('div[class="common-table-body"]')
find_element_by_tag_name_tmp('tbody')
tr_num = find_elements_by_tag_name_tmp('tr')
print('all tr is :',tr_num)
for i in range(tr_num):
choose_element_from_elements(i)
data_str = text()
#print ('data_str is : ',data_str)
data_list = data_str.split()
print('data_list is : ',data_list)
print('data_list type is : ',type(data_list))#list
if ip in data_list[1]:
find_element_by_tag_name_tmp('span')
click()
sleep(6)
if __name__ == '__main__':
login_skylar()
sleep(2)
switch_page('终端管理','终端概况')
sleep(3)
click_machine_ip(ip='172.24.83.102')
sleep(5)
输出:
data_list is : ['yzwvm-1022-PC(离线)', '192.168.76.137', '0', '0']
data_list type is : <class 'list'>