Your target element inside a <frame>
:
<iframe src="https://fs.global-e.com/Checkout/v2/f77781eb-a7c0-43e2-822a-3ca96e8658f0?gaSesID=361925132.674171348.583&gaMerchantClientInfo=undefined@undefined&chkcuid=3ef950c0-4c7d-4cfe-bab5-3a1ed7035318&isNECAllowed=true&vph=631&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: 2196px;"></iframe>
You need to switch it first:
#after clicked checkout button
time.sleep(10)
driver.switch_to.frame(driver.find_element_by_id("Intrnl_CO_Container"))
time.sleep(10)
element3 = driver.find_element_by_xpath('//*[@id="CheckoutData_BillingFirstName"]')
element3.send_keys("My First Name")
But there is a better way to wait in selenium, for detail you can read the @pcalkins suggestion.
After clicked checkout button, you can add following code:
#after clicked checkout button
wait = WebDriverWait(driver, 20)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID, 'Intrnl_CO_Container')))
element3 = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="CheckoutData_BillingFirstName"]'))).click()
element3.send_keys("My First Name")
Please import:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…