【发布时间】:2020-06-20 18:49:42
【问题描述】:
我正在尝试使用 selenium + python 将信用卡值输入到 Shopify 网站。用于输入卡片值的框位于 iframe 中,我不确定如何切换到此 iframe。
我目前有这个代码:
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,
'//*[@id="card-fields-number-950kvfi9pbn00000"]'))
).send_keys(card_number, Keys.TAB, name_on_card, Keys.TAB,expiry_date, cvv)
driver.switch_to.default_content()
但这会返回错误:
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it(...
selenium.common.exceptions.TimeoutException: Message:
如此有效,找不到元素...
这是页面的 HTML: (https://gyazo.com/80d9d3c941c62ededc81d5fbc327a71f)
我想要一些有关如何访问此元素的帮助,我还尝试通过将 id 更改为此标记的父级来访问它。我还添加了time.sleep(20),因此我可以确定页面已完全加载,但我仍然遇到同样的错误。
【问题讨论】:
标签: python selenium iframe shopify