- 定义了一个函数findname.py,获得含有关键字的列表名称,并返回list最大值;
def fnn(names, keys):
k = []
for name in names:
#循环获得属性为value的值
s = name.get_attribute("value")
#找到包含关键字keys的字符串
if keys in s:
k.append(s)
newest = max(k)
return newest
#先定位到列表,在定位input,返回list
names = driver.find_element_by_xpath(
"//*[@id='DataTables_Table_0']/tbody").find_elements_by_tag_name("input")
#关键字keys为zs
name = findname.fnn(names, "zs")
driver.find_element_by_link_text(name).click()
-
字符串包含判断:关键字 in string;
-
def fnn(names, keys):
k = []
for name in names:
#循环获得属性为value的值
s = name.get_attribute("value")
#找到包含关键字keys的字符串
if keys in s:
k.append(s)
newest = max(k)
return newest