I am trying to submit the hackerRank website challenge through automation using puppeteer. After the solve challenge button is clicked the code goes on next page but doesn't select the the checkbox element i.e 'Text against custom input'
const puppeteer = require("puppeteer");
const url = "https://www.hackerrank.com/auth/login";
(async function () {
try {
const browserInstance = await puppeteer.launch({
headless: false,
slowMo: true,
args: ["--start-fullscreen"],
defaultViewport: null,
});
let newTab = await browserInstance.newPage();
await newTab.goto(url);
await newTab.waitForSelector("#input-1");
await newTab.click("#input-1");
let email = "some-email.com";
await newTab.type("#input-1", email, {
delay: 50,
});
let password = "some-password";
await newTab.waitForSelector("#input-2");
await newTab.click("#input-2");
await newTab.type("#input-2", password, {
delay: 50,
});
await newTab.click('button[data-analytics="LoginPassword"]', { delay: 50 });
await waitAndClick('a[data-attr1="algorithms"]', newTab);
await waitAndClick('input[value="warmup', newTab);
let allChallenges = await newTab.$$(
".ui-btn.ui-btn-normal.primary-cta.ui-btn-line-primary.ui-btn-styled",
{ delay: 50 }
);
await questionSolver(allChallenges[0], newTab);
console.log("Total Questions", allChallenges.length);
} catch (error) {
console.log(error);
}
})();
async function questionSolver(challenge, page) {
await challenge.click();
let inputIsClicked = await waitAndClick(".checkbox-input", page);
return inputIsClicked;
}
async function waitAndClick(selector, cpage) {
await cpage.waitForSelector(selector);
let selectorClicked = cpage.click(selector);
return selectorClicked;
}
