【发布时间】:2021-09-24 00:59:00
【问题描述】:
我正在编写一个代码,它可以使用 Selenium + BS4 在 Amazon Seller Central 上自动化一些流程。 我想通过链接文本找到一个元素,但它不起作用,, 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)
我需要帮助:(
【问题讨论】:
-
如果我不能使用“链接文本”,因为它不是 标签。有什么方法可以通过使用我的代码之类的变量找到它?
标签: python selenium beautifulsoup automation amazon