Ich versuche, auf die Eingabefelder für die Zahlungsinformationen zu klicken, dann übergebe Schlüssel an diese Eingabefelder. Ich entdeckte, dass sie in iframes sind, aber ich hatte kein Glück, zu den verschiedenen Rahmen zu wechseln. Ich habe ein Bild von der HTML-Datei sowie von der Art der Seite angehängt. Jede Hilfe wäre willkommen! Hier ist mein Code:Senden von Schlüsseln an Eingabefeld mit Selenium
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import UnexpectedAlertPresentException
from selenium.common.exceptions import ElementNotVisibleException
import time
driver = webdriver.Chrome()
print('Browser Successfully Iitialized!')
driver.get('https://kith.com/products/new-balance-696-beige-pink')
input()
print('Beginning Checkout Process!')
print('Posting Customer Information...')
while True:
try:
driver.find_element_by_id('g-recaptcha-response')
print('Captcha Detected!')
print('Solve Captcha...')
captcha = True
break
except NoSuchElementException:
print('No Captcha Detected!')
captcha = False
break
email_field = driver.find_element_by_xpath('//*[@id="checkout_email"]').send_keys('[email protected]')
fname_field = driver.find_element_by_xpath('//*[@id="checkout_shipping_address_first_name"]').send_keys('John')
lname_field = driver.find_element_by_xpath('//*[@id="checkout_shipping_address_last_name"]').send_keys('Doe')
address_field = driver.find_element_by_xpath('//*[@id="checkout_shipping_address_address1"]').send_keys('12345 Street')
city_field = driver.find_element_by_xpath('//*[@id="checkout_shipping_address_city"]').send_keys('City')
state_dropdown = driver.find_element_by_xpath('//*[@id="checkout_shipping_address_province"]/option[22]').click()
zipcode_field = driver.find_element_by_xpath('//*[@id="checkout_shipping_address_zip"]').send_keys('46001')
phone_field = driver.find_element_by_xpath('//*[@id="checkout_shipping_address_phone"]').send_keys('1234567891')
if captcha == True:
while captcha is True:
time.sleep(3)
try:
cont_shipping = driver.find_element_by_name('button').click()
button = driver.find_element_by_class_name('btn__content')
if button.text == 'Continue to payment method':
print('Captcha Solved!')
captcha = False
except:
captcha = True
driver.find_element_by_name('button').click()
print('Posting Shipping Information...')
shipping_url = driver.current_url
shipping_url.replace("previous_step=contact_information&step=shipping_method", "")
payment_url = shipping_url + 'previous_step=shipping_method&step=payment_method'
driver.get(payment_url)
print('Posting Payment Information...')
try:
el = driver.find_element_by_xpath('//*[@id="payment-gateway-subfields-1427382"]/div[3]/div[2]')
el.click()
el.send_keys('John Doe')
except ElementNotVisibleException:
print('Error')
Image of the html and screen of the input field/fields
Vielen Dank für diese Antwort! Glauben Sie, dass Sie mir helfen könnten, wie ich Schlüssel an die Kreditkarteninformationen (Kreditkartennummer, Name auf Karte, Ablaufdatum und Sicherheitscode) senden kann? – A1pickups