使用 Python 和 Selenium 找到该元素后,我无法单击它

I can not click on this element after finding it using Python and Selenium

class SeleniumConfig(unittest.TestCase):

def __init__(self):
    super().__init__()
    self.absolute = os.path.dirname(os.path.abspath(__file__)) + "/chromedriver.exe"
    options = webdriver.ChromeOptions()
    options.add_argument("--start-maximized")
    self.driver = webdriver.Chrome(self.absolute, options=options)


def jupiter_4(self):
    self.driver.get('http://jupiter.cloud.planittesting.com')
    self.assertIn("Jupiter Toys", self.driver.title)
    self.driver.find_element_by_id("nav-shop").click()
    try:
        WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located((By.CLASS_NAME, "products.ng-scope"))
        )
    except NoSuchElementException as error:
        print(error)
    cow = self.driver.find_elements_by_xpath("/html/body/div[2]/div/ul/li[6]/div/p/a[@class='btn btn-success']")
    cows = self.driver.execute_script("add(item);", cow)
    print(cows)
    for each in cow:
        print(each.text)
        print(each)

    time.sleep(10)
    self.driver.quit()

当我不使用 .click() 方法时,它 returns 它是一个字符串 买

然而,当我尝试 .click() 时,它 returns 我的列表越界了

我不确定为什么它会返回一个列表,因为我已经为按钮添加了准确的完整路径。

牛=self.driver.find_elements_by_xpath(/html/body/div[2]/div/ul/li[6]/div/p/a[@class='btn btn-success']" ) 尝试: 对于每一头奶牛: 打印(each.text) 打印(each.click()) 除了属性错误: 通过

这个列表好像有几个索引,如果我遍历它就可以点击