I am trying to make a script to automatically checkout on a Shopify site. When I try to fill in the field that is asking for the credit card, selenium is not allowing me to send in the keys into the field and is saying that the element is not interactable. I’ve already tried clicking it, but it’s still not letting me enter in the information. Does anyone know what to do?
driver.find_element_by_xpath('//div[@data-card-field-placeholder="Card number"]').click()
driver.find_element_by_xpath('//div[@data-card-field-placeholder="Card number"]').send_keys("1234")
is the link I am trying to test this out on
2
Answers
you should use element with input tag or any interactable tag to use sendKeys
see if the parent div element has a child input tag element and find that element instead of div
Also there is iframe inside , so if the input tag is inisde iframe , then first find iframe element then use
and then find the input element
each iframe are isolated session , you cannot talk to other frame from one frame so if you want to access elements inside one frame you have to switch to that framefirst
and also once done switch back to main frame using
driver.switch_to.default_content()
To access the page to provide the credit card details we need to move beyond the CONTACT INFORMATION information page. Hence, couldn’t access it directly.
Ideally Creditcard Number fields are with in an
<iframe>
. Hence to access the Creditcard Number field within an<iframe>
so you have to:Induce WebDriverWait for the desired frame to be available and switch to it.
Induce WebDriverWait for the desired element to be clickable.
You can use either of the following Locator Strategies:
Using
CSS_SELECTOR
:Using
XPATH
:Note : You have to add the following imports :
Reference
You can find a couple of relevant discussions in:
tl; dr
You can find a couple of relevant detailed discussions in: