问题描述
我正在尝试制作一个自动结账系统,但我似乎无法在此付款箱的字段中发送密钥。即使我尝试隐式等待并等待它加载它仍然不起作用。
checkout = driver.find_element_by_id("number")
checkout.send_keys("9848432")
这是a link!
这是您在进入付款页面之前需要填写信息的网址,这是我遇到问题的地方
解决方法
它可能在嵌套的 iframe 中。由于没有正确的可重现代码而进行了类似的检查。
<iframe src="https://fs.global-e.com/Checkout/v2/598d87e9-cd85-4f61-84df-81e345d62f05?gaSesID=526107767.603750114.583&gaMerchantClientInfo=undefined@undefined&chkcuid=b51f4449-13e2-4883-92ba-2641bb06ec51&isNECAllowed=true&vph=663&ift=87" class="Intrnl_CO_Container" id="Intrnl_CO_Container" name="Intrnl_CO_Container" allowtransparency="true" width="100%" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" height="1000px" style="height: 3101px;">
<iframe id="secureWindow" class="clear-fix clearfix" allowtransparency="true" style="width: 100%; min-height: 160px; height: 165px;" src="https://securev2.global-e.com/payments/CreditCardForm/598d87e9-cd85-4f61-84df-81e345d62f05/11">
<input autocomplete="off" class="form-control input-validation-error" data-type="unknown" data-type-id="1" data-val="true" data-val-luhn="Card number not valid" data-val-luhn-allowempty="False" data-val-luhn-allowspaces="False" data-val-required="Card number" id="cardNum" name="PaymentData.cardNum" pattern="[0-9]{13,16}" placeholder="Card number" type="tel" value="">
</iframe>
</iframe>
解决方法:
wait = WebDriverWait(driver,10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID,'Intrnl_CO_Container')))
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID,'secureWindow')))
checkout = wait.until(EC.presence_of_element_located((By.ID,"cardNum")))
checkout.send_keys("9848432")
导入
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC