python+selenium中,怎么获得中层标签的文本值

2024-12-22 09:14:16
推荐回答(1个)
回答1:

Candidate_name = driver.find_element_by_xpath("//div[contains(text(),"考生姓名")]//u").text
Ticket_num = driver.find_element_by_xpath("//div[contains(text(),"准考证号")]//u").text
print "The Candidate's name is %s" % str(Candidate_name)
print "The Ticket number is %s" % str(Ticket_num)
这样就可以获取考生姓名以及准考证号了。