This commit is contained in:
TheNetsky
2023-09-25 12:16:40 +02:00
parent 0a675dd6e0
commit c802492f18
27 changed files with 2115 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
import { Page } from 'puppeteer'
import { MorePromotion, PromotionalItem } from '../../interface/DashboardData'
import { getLatestTab } from '../../BrowserUtil'
import { log } from '../../util/Logger'
import { wait } from '../../util/Utils'
export async function doPoll(page: Page, data: PromotionalItem | MorePromotion) {
log('POLL', 'Trying to complete poll')
try {
const selector = `[data-bi-id="${data.offerId}"]`
// Wait for page to load and click to load the quiz in a new tab
await page.waitForSelector(selector, { timeout: 5000 })
await page.click(selector)
const pollPage = await getLatestTab(page)
const buttonId = `#btoption${Math.floor(Math.random() * 2)}`
await pollPage.waitForSelector(buttonId)
await pollPage.click(buttonId)
await wait(2000)
await pollPage.close()
log('POLL', 'Completed the poll successfully')
} catch (error) {
log('POLL', 'An error occurred:' + error, 'error')
}
}