Search code examples
pythonplaywright

Error when trying to locate Email textbox


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: enter image description here

This is the locator that I am using:

self.email_txt = page.locator('#email')

Here is the error message: enter image description here


Solution

  • 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')