Python Selenium:无法在Amazon上定位元素

Python Selenium:无法在Amazon上定位元素,python,python-3.x,selenium,selenium-webdriver,selenium-chromedriver,Python,Python 3.x,Selenium,Selenium Webdriver,Selenium Chromedriver,我一直在尝试填充输入: <input id="turbo-checkout-pyo-button" data-testid="" class="a-button-input" type="submit" value="Place your order" aria-labelledby="turbo-checkout-place-order-button-announce"

我一直在尝试填充输入:

<input id="turbo-checkout-pyo-button" data-testid="" class="a-button-input" type="submit" value="Place your order" aria-labelledby="turbo-checkout-place-order-button-announce">
我总是得到:

找不到元素:{“方法”:“css选择器”,“选择器”:“[id=“turbo checkout pyo button”]”


它似乎不起作用。我不知道我是否提供了足够的信息,所以如果你需要更多的信息来帮助我,请告诉我

为什么要使用=两次? 只需使用:

placeorderBtn = browser.find_element_by_id("turbo-checkout-pyo-button")
另外,等待此按钮变为可单击。 消息说您正在使用css选择器。 正确使用它为ID元素添加了。 在您的情况下,它将是:

placeorderBtn = browser.find_element_by_css_selector("#turbo-checkout-pyo-button")
placeorderBtn.click()
尝试2: 根据评论: 请尝试以下xpath:

locator = "//input[text() = 'Place your order']"
或者

尝试3:

单击“使用”

from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

wait = WebDriverWait(driver, 20)
wait.until(EC.element_to_be_clickable(
                (By.XPATH, "//span[text() = 'Place your order']")))
locator = driver.find_element_by_xpath('//span[text() = 'Place your order']')
locator.click()
尝试4:

使用定位器:

placeorderBtn = browser.find_element_by_id("turbo-checkout-place-order-button-announce") 
placeorderBtn.click()

欢迎来到Stackoverflow。尝试创建一个仍然给我:找不到元素:{“方法”:“css选择器”,“选择器”:“#turbo checkout pyo button”}页面是否已完全加载?此外,我无法升级投票,因为我没有足够的声誉,哈哈,但我在查看链接后肯定会接受你的答案!再次感谢你!没有关系!我弄明白了!非常感谢你的时间和帮助!这对我来说真的很重要。虽然我是新手,但我花了好几个小时在这上面,而你帮了我大忙!再次感谢您的帮助!
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

wait = WebDriverWait(driver, 20)
wait.until(EC.element_to_be_clickable(
                (By.XPATH, "//span[text() = 'Place your order']")))
locator = driver.find_element_by_xpath('//span[text() = 'Place your order']')
locator.click()
placeorderBtn = browser.find_element_by_id("turbo-checkout-place-order-button-announce") 
placeorderBtn.click()