python - 如何通过 Splinter 填写 Stripe Element 表单?
问题描述
这些是条纹元素:https ://stripe.com/docs/stripe-js/elements/quickstart 。
我想使用 Splinter 测试它们,但不能在保留字符顺序的同时填写输入。
解决方案
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')
推荐阅读
- node.js - 安装 Angular Material 后的 Angular 编译警告
- timer - 在 CAPL 中创建一个可暂停的计时器
- google-apps-script - 粘贴到错误的单元格
- javascript - Google Apps 脚本删除自动电子邮件中的 html 标签
- typescript - 在 TypeScript 中复制相同键属性错误
- postgresql - 加速 Postgres Group
- multithreading - SOCK_STREAM 套接字的多线程使用
- c# - 如何使用 Excel-DNA 构建 XLL
- javascript - 单击锚元素时:目标元素上是否触发了任何事件?
- r - 使用超过 11 种颜色更改堆栈条图中的颜色