【问题标题】:How to fill in Stripe Element form via Splinter?如何通过 Splinter 填写 Stripe Element 表单?
【发布时间】:2018-08-08 16:11:34
【问题描述】:

这些是条纹元素:https://stripe.com/docs/stripe-js/elements/quickstart

我想使用 Splinter 测试它们,但在保留字符顺序的同时无法填写输入。

【问题讨论】:

    标签: python selenium integration-testing stripe-payments splinter


    【解决方案1】:
    def fill_in_stripe_input(browser, iframe_name, input_name, value):
        # every Stripe Element is in a separate iframe
        with browser.get_iframe(iframe_name) as iframe:
            # get the internal Selenium element.
            selenium_input = iframe.find_by_css('input[name=' + input_name + ']').first._element
            # just send_keys('424242...') doesn't work, because order of characters may get mixed up
            for character in value:
                selenium_input.send_keys(character)
    
    from splinter import Browser
    browser = Browser('chrome', executable_path='/usr/local/bin/chromedriver')
    fill_in_stripe_input(browser, iframe_name='__privateStripeFrame3', input_name='cardnumber', value='4242424242424242')
    fill_in_stripe_input(browser, iframe_name='__privateStripeFrame4', input_name='exp-date', value='0320')
    fill_in_stripe_input(browser, iframe_name='__privateStripeFrame5', input_name='cvc', value='999')
    

    【讨论】:

      猜你喜欢
      • 2013-06-21
      • 1970-01-01
      • 2017-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-09
      • 2011-08-24
      • 2018-12-04
      相关资源
      最近更新 更多