This commit is contained in:
TheNetsky
2023-10-02 11:52:12 +02:00
parent 8fef05a2b7
commit e8cb195f54
17 changed files with 341 additions and 149 deletions

View File

@@ -1,9 +1,11 @@
import { Page } from 'puppeteer'
import { MorePromotion, PromotionalItem } from '../../interface/DashboardData'
import { getLatestTab } from '../../BrowserUtil'
import { log } from '../../util/Logger'
import { randomNumber, wait } from '../../util/Utils'
import { MorePromotion, PromotionalItem } from '../../interface/DashboardData'
export async function doPoll(page: Page, data: PromotionalItem | MorePromotion) {
log('POLL', 'Trying to complete poll')
@@ -18,7 +20,7 @@ export async function doPoll(page: Page, data: PromotionalItem | MorePromotion)
const buttonId = `#btoption${Math.floor(randomNumber(0, 1))}`
await pollPage.waitForSelector(buttonId)
await pollPage.waitForSelector(buttonId, { visible: true, timeout: 5000 })
await pollPage.click(buttonId)
await wait(2000)
@@ -26,6 +28,6 @@ export async function doPoll(page: Page, data: PromotionalItem | MorePromotion)
log('POLL', 'Completed the poll successfully')
} catch (error) {
log('POLL', 'An error occurred:' + error, 'error')
log('POLL', 'An error occurred:' + JSON.stringify(error, null, 2), 'error')
}
}