2017-05-18 7 views
1

支払い情報の入力フィールドをクリックして、入力フィールドにキーを送信しようとしています。私はそれらがiframeにあることを発見しましたが、私は運を別のフレームに切り替えることはありませんでした。私はhtmlの写真とページの外観を添付しました。どんな助けもありがとう!Seleniumで入力フィールドにキーを送信する

frame_element = WebDriverWait(driver, 120).until(EC.visibility_of_element_located((By.name, "injectedUl")) 
driver.switchTo().frame(driver.find_element_by_name("injectedUl")); 
driver.find_element_by_id("email"))send_keys("[email protected]"); 
driver.find_element_by_id("password")send_keys("asdsa"); 
driver.find_element_by_id("btnLogin")).click(); 

ペイメントゲートウェイオプション(電子メール、パスワード...)はiframeので、最初のスイッチの下に存在:

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

答えて

0

は、後のPayPalボタンをクリックし、以下のコードを使用します。ここに私のコードですiframeを実行してから操作を実行してください

+0

この返信いただきありがとうございます!クレジットカード情報(クレジットカード番号、カード上の名前、有効期限、セキュリティコード)に鍵を送る方法を手助けできると思いますか? – A1pickups

関連する問題