2020-09-10
# 通过文本内容精准定位元素。可能因为各种页面情况,经常定位不到元素
browserdriver.find_element_by_xpath('//div[text()="活动频道"]')
# 若要定位其它标签元素(如:td,span等),只需要替换div即可
例如:ul = browserdriver.find_element_by_xpath('//span[text()="活动频道"]').click()
# 通过文本内容模糊定位元素
browserdriver.find_element_by_xpath('//div[contains(text(),"活动频道")]')
例如:li = browserdriver.find_element_by_xpath('//span[contains(text(),"活动频道")]').click()