我正在写一个代码,可以自动化亚马逊销售商中心与Selenium + BS4的几个过程。我想通过链接文本查找元素,但在,,red rectangle is the part that I want to find by link text中不起作用
我可以通过类名或xpath找到元素,但找不到带有链接文本的相同元素。我需要通过链接文本来查找元素,因为我将使用帐户的名称作为我同事的变量。the link text in the tag and the rectangle on the left side has same text
customer = "variable for my cowrkers"
browser.find_element_by_class_name('dropdown-button').click()
browser.find_element_by_xpath('//*[@id="partner-switcher"]/div/button').click()
time.sleep(7)
###### problem
elem = browser.find_elements_by_link_text(customer).click()
print(elem)
我需要帮助:
发布于 2021-09-23 19:56:46
您可以尝试使用xpath
find_element_by_xpath("//div[@class='picker-name' and text() = 'account text']")
所以,
find_element_by_xpath("//div[@class='picker-name' and text() = '" + customer + "']")
https://stackoverflow.com/questions/69308372
复制相似问题