Using playwright I am trying to do a simple login operation on a website
The steps are simple :
- click on a Login button
- Try to enter an email (Playwrights fails here)
I can see that the selector is getting to the correct field but fails to enter the username into the input (and times out instead)
async def login(url, username, password):
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
page = await browser.new_page()
await page.goto(url)
print(await page.title())
# Click login
await page.click('xpath=/html/body/nav[2]/div/ul/li[4]/a')
await page.pause()
# Wait for email popup
# await page.type('[placeholder="Enter your email address and hit enter"]', username)
await page.type('//input[@type="email" and not(@disabled)]', username, delay = 10) # fails here
await page.click('xpath=/html/body/app-main/app-widget/screen-layout/main/current-screen/div/screen-login/p[2]/button')
asyncio.run(login(url, username, password))
The error that I get is a timeout :
return await self.inner_send(method, params, False)
File "/Users/work/Documents/Code/venv/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 63, in inner_send
result = next(iter(done)).result()
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "//input[@type="email" and not(@disabled)]"
============================================================
This essentially means playwright was waiting for this element and no luck finding it, so it explodes after the default 30 seconds
I tried using
- different xpaths
- CSS selectors
- Text selectors
I also tried using selenium and strangely the behavior is the same.
The website in question: https://epaper.thehindu.com/
That particular element on the website that I am trying to type into
<input _ngcontent-ttw-c171="" fieldloginemail="" type="email" placeholder="Enter your email address and hit enter" id="email" class="sub margin-0 empty" autocorrect="off" autocapitalize="off">
The question is : why playwright cannot find this input? (Playwright Inspector can clearly see it in broad daylight)