diff --git a/index.js b/index.js index 37da977..5f5ef58 100644 --- a/index.js +++ b/index.js @@ -5,16 +5,19 @@ const delay = (ms) => { }); } let driver; + +const myInstanceIDs = [200339, 199169, 197195, 195883, 194294, 188057, 181297]; + const login = async ()=> { driver = await new selenium.Builder().forBrowser('chrome').build(); await driver.get('https://outcomes.generalassemb.ly/'); let selection = selenium.By.id('identify_email'); - let element = driver.findElement(selection); + let element = await driver.findElement(selection); element.sendKeys('matt.huntington@generalassemb.ly'); selection = selenium.By.id('baseForm'); - element = driver.findElement(selection); + element = await driver.findElement(selection); element.submit(); await delay(2000); @@ -28,39 +31,68 @@ const login = async ()=> { element.sendKeys('Hunt!ngt0n80!'); selection = selenium.By.css('form'); - element = driver.findElement(selection); + element = await driver.findElement(selection); element.submit(); await delay(2000); selection= selenium.By.css('a') - element = await driver.findElements(selection); + let elements = await driver.findElements(selection); - element[1].click(); + elements[1].click(); } const search = async () => { let selection = selenium.By.id('program'); - let element = driver.findElement(selection); + let element = await driver.findElement(selection); let select = new selenium.Select(element); await select.selectByVisibleText('Software Engineering Immersive Remote'); selection = selenium.By.id('metro'); - element = driver.findElement(selection); + element = await driver.findElement(selection); select = new selenium.Select(element); await select.selectByVisibleText('Online'); selection = selenium.By.id('from'); - element = driver.findElement(selection); + element = await driver.findElement(selection); element.sendKeys('01/01/2021'); selection = selenium.By.id('filter-form'); - element = driver.findElement(selection); + element = await driver.findElement(selection); element.submit(); } const main = async () => { await login(); - await delay(10000); - search(); + await delay(8000); + await search(); + await delay(2000); + + let selection = selenium.By.css('table td>a'); + let elements = await driver.findElements(selection); + + for(currentElement of elements){ + + currentElement.click(); + + await delay(3000); + + try{ + selection = selenium.By.css('.full-time-90-days-actuals'); + let element = await driver.findElement(selection); + const innerHTML = await element.getAttribute('innerHTML'); + const percent = parseInt(innerHTML.match(/([0-9]*%)/)[0].replace('%','')) + const url = await driver.getCurrentUrl(); + const instanceID = parseInt(url.match(/[0-9]*$/i)[0]); + if(myInstanceIDs.includes(instanceID)){ + console.log("me -->", instanceID, percent); + } else { + console.log(instanceID, percent); + } + } catch (error) { + //console.log(error); + } + + await driver.navigate().back(); + } } main()