Sunday, May 12, 2024
162
rated 0 times [  169] [ 7]  / answers: 1 / hits: 7924  / 3 Years ago, wed, april 14, 2021, 12:00:00

Im trying to write the login function for this website:


and this is my code:


const { chromium, firefox, webkit } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: false, slowMo: 50 });
const context = await browser.newContext({
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
});
const page = await context.newPage();
await page.goto('url');
await page.type('input[name="userName"]', 'some@account');
await page.type('input[name="password"]', 'somepassword');
await page.click('text=Sign In');
await page.waitForTimeout(2000);
await context.close();
})();

I put headless: false so I can see what's going on, but input values are not filling and sign in button is not clicked, any help?


More From » webautomation

 Answers
2

You have three elements there with the 'input[name="userName"]' selector. I bet the one you are trying to type on is not the first one.

You could try improving your selector. For instance, with something like this '#signInFormPage input[name="userName"]'.


[#1478] Thursday, April 8, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dustin

Total Points: 599
Total Questions: 105
Total Answers: 106

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
dustin questions
;