英文:
Error when trying to locate Email textbox
问题
我正在尝试定位一个网页上支付弹出窗口中的电子邮件文本框,但在尝试这样做时出现了一个“等待定位器”的错误。弹出窗口上的其他元素也遇到了相同的问题。我已成功定位了其他页面上的元素。在定位弹出窗口上的元素时,是否需要特别注意某些事项?
这是我正在使用的定位器:
self.email_txt = page.locator('#email')
这是错误消息:
英文:
I'm trying to locate a, email textbox on a payment popup on a webpage, but I encounter a "waiting for locator" error when I attempt to do so. Its the same issue with the other elements on the popup. I have successfully located elements on the other pages. Is there something I have to do specifically when locating elements on popups?
Here is the payment popup with the email text box I wish to locate along with the html:
This is the locator that I am using:
self.email_txt = page.locator('#email')
答案1
得分: 2
我已经看到其他网站在 iframe 内运行 Stripe 支付。如果这也是您的情况,您必须在您的选择器中指定 iframe,就像这样:
stripe_iframe = page.frame_locator('iframe[name="stripe_checkout_app"]')
await stripe_iframe.get_by_placeholder('Email').fill('test@example.com')
await stripe_iframe.get_by_placeholder('Card number').fill('1111222233334444')
英文:
I have seen other sites running Stripe payment inside and iframe. If that is your case, you must specify the iframe in your selector, like this:
stripe_iframe = page.frame_locator('iframe[name="stripe_checkout_app"]')
await stripe_iframe.get_by_placeholder('Email').fill('test@example.com')
await stripe_iframe.get_by_placeholder('Card number').fill('1111222233334444')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论