下面给出的代码片段绝对适合您:
driver.find_element_by_xpath("//div[@class='col-sm-2 col-md-2 col-lg-2 menu-button'][contains(text(),'Activity R')]")
如果上面的方法不起作用,下面的方法也应该起作用:
lst_menu = driver.find_elements_by_xpath("//div[@class='col-sm-2 col-md-2 col-lg-2 menu-button']")
for item in lst_menu:
if (item.get_attribute("text") == 'Activity Report'):
item.click()