[英]Trying to click continue button on paypal with Selenium in python
Button: before按钮:之前
Button: After按钮:之后
I've tried many ways to get this working.我已经尝试了很多方法来让这个工作。 here's what I have
这就是我所拥有的
mainagree = WebDriverWait(driver, 15).until(
EC.presence_of_element_located((By.XPATH, "//button[@id='payment-submit-btn']"))
)
mainagree.click()
print('clicked')
I've tried locating it with ID and xpath, both won't click.我试过用 ID 和 xpath 定位它,两者都不会点击。 I did a bit research on iframe,
我对 iframe 做了一些研究,
but I don't think that particular button is under any iframe.但我不认为该特定按钮位于任何 iframe 下。 I am really lost on this one.
我真的迷失了这个。
Based on discussion in another thread here , let's try two different approaches for syncing and clicking the button:根据此处另一个线程中的讨论,让我们尝试两种不同的同步和单击按钮的方法:
agree_ctn_button = WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.XPATH, "//div[contains(@class, 'modal-foreground-container')]//div[contains(@class, 'CheckoutButton_buttonWrapper')]//button[@id='payment-submit-btn']"))) driver.execute_script("arguments[0].scrollIntoView();", agree_ctn_button) driver.execute_script("arguments[0].click();", agree_ctn_button)
OR或者
agree_ctn_button = WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.XPATH, "//div[contains(@class, 'modal-foreground-container')]//div[contains(@class, 'CheckoutButton_buttonWrapper')]//button[@id='payment-submit-btn']"))) driver.execute_script("document.getElementById('payment-submit-btn').click()")
Do either of these code snippets work?这些代码片段中的任何一个都有效吗?
mainagree = WebDriverWait(driver, 15).until(
EC.presence_of_element_located((By.XPATH, "//button[@id='payment-submit-btn']"))
)
driver.execute_script("arguments[0].click();", mainagree)
Try the following out to click on the mainagree button.尝试以下操作以单击 mainagree 按钮。 If it's in an iframe you'd get NosuchElement error.
如果它在 iframe 中,您会收到 NosuchElement 错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.