const {Builder, By, Key, until} = require('selenium-webdriver'); const prompt = require('prompt'); prompt.start() function checkSite() { } (async function rateProfs() { let driver = await new Builder().forBrowser('chrome').build(); console.log("mapua-profrater: Driver Created.") try { // console.log("mapua-profrater: Opening MyMapua") // await driver.get('https://my.mapua.edu.ph/Student/Default.aspx') // console.log("Please Login to continue.") // await driver.wait(until.urlIs("https://my.mapua.edu.ph/Student/Default.aspx")); // console.log("mapua-profrater: Logged in successfuly.") // console.log("mapua-profrater: Redirecting to Faculty Evaulation...") // await driver.get('https://my.mapua.edu.ph/Student/FacultyEval.aspx'); prompt.get(['interactive'], (err, result) => { if (result.interactive == 'Y' || result.interactive == 'y') { rateInteractive(); } else { let min = prompt('Enter Minimum Rating (1-10): '); let max = prompt('Enter Maximum Rating (1-10): '); rateRandom(min, max); } }) } catch (err) { console.log("Error: " + err); await driver.quit(); } })(); function rateInteractive() { } function rateRandom(min, max) { do { for (i; i < 33; i++) { let element = "ct100_cphMain_lst" + (i + 1); console.clear(); console.log("Rating Question #" + (i + 1) + "..."); let rating = Math.floor(Math.random() * (max - min + 1)) + min; console.log("Rating: " + rating); driver.findElement(By.id, element).sendKeys(rating); } let tryAgain = prompt('Rate Again? (Y/N [N])'); if (tryAgain == 'Y' || tryAgain == 'y') { i = 0; } else { break; } } while (true); }