-1

I'm writing a code which can automate few process on Amazon Seller Central with Selenium + BS4. I want to find an element by link text but it's not workin,, red rectangle is the part that I want to find by link text

I can find the element by class name or xpath but I can't find the same element with link text. I need to find the element by link text cuz I'm going to use the account's name as a variable for my coworkers. 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)

I need help :(

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470

1 Answers1

2

You can try xpath

find_element_by_xpath("//div[@class='picker-name' and text() = 'account text']")

So,

find_element_by_xpath("//div[@class='picker-name' and text() = '" + customer + "']")
QHarr
  • 83,427
  • 12
  • 54
  • 101