UI自动化:多重定位

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/pingsha_luoyan/article/details/98168132

#encoding:utf-8
from selenium import webdriver
import json
import time
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
driver= webdriver.Firefox()

url="http://47.92.220.226/webdriver/"
driver.get(url)
# 多重定位
ele_table=driver.find_element_by_id(u'table')
ele_table_trs=ele_table.find_elements_by_tag_name(u'tr')
may=[]
june=[]
for i in range(len(ele_table_trs)):
    if i==0:
        continue
    else:
        tds=ele_table_trs[i].find_elements_by_tag_name(u'td')
        for j in range(len(tds)):
            if j==1:
                may.append(tds[j].text)
            elif j==2:
                june.append(tds[j].text)
            else:
                continue
print may
print june
may_sum=0
june_sum=0
for m in may:
    may_sum+=int(m)
for j in june:
    june_sum+=int(j)
print may_sum
print  june_sum


driver.back()
ele_optationTest=driver.find_element_by_link_text(u'页面元素操作练习')
ele_optationTest.click()
# 文本框
ele_by_id1_1=driver.find_element_by_id(u'1_1')
ele_by_id1_1.send_keys(u'121

猜你喜欢

转载自blog.csdn.net/pingsha_luoyan/article/details/98168132