Search code examples
pythonpytestplaywright

AttributeError: 'NoneType' object has no attribute 'fill'


using Playwright automation I would like to insert email into a simple input field: input field

The site code how the Input is defined:

enter image description here

My code in Playwright:

form = page.locator("#register-email").click()
form.fill("[email protected]")

The result is error "object has no attribute 'fill'":

form = page.locator("#register-email").click()
>       form.fill("[email protected]")
E       AttributeError: 'NoneType' object has no attribute 'fill'

Any idea, what could be wrong?


Solution

  • The way you have written this code, form is assigned to the result of click(), which returns nothing:

    form = page.locator("#register-email").click()
    

    I believe you should separate that code into two statements:

    form = page.locator("#register-email")
    form.click()