avoid crash when field not found

This commit is contained in:
2022-09-15 18:52:49 +02:00
parent 679d690f93
commit 47fecec58f
+4 -4
View File
@@ -146,12 +146,10 @@ class CommandorPage {
} }
async inputName(page) { async inputName(page) {
try {
if (!page.isClosed()) {
await page.locator(LAST_NAME).focus() await page.locator(LAST_NAME).focus()
await delay(getRandomWaitTime()) await delay(getRandomWaitTime())
try {
if (!page.isClosed()) {
await page.locator(LAST_NAME).fill(this.contact.lastName) await page.locator(LAST_NAME).fill(this.contact.lastName)
await page.locator(FIRST_NAME).focus() await page.locator(FIRST_NAME).focus()
await delay(getRandomWaitTime()) await delay(getRandomWaitTime())
@@ -257,6 +255,8 @@ class CommandorPage {
try { try {
if (!page.isClosed()) { if (!page.isClosed()) {
page.evaluate((solution) => { page.evaluate((solution) => {
let element = document.getElementById("g-recaptcha-response");
if (element != null)
document.getElementById("g-recaptcha-response").innerHTML = solution; document.getElementById("g-recaptcha-response").innerHTML = solution;
}, solution) }, solution)
this.clickValid(); this.clickValid();