You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.7 KiB

const selenium = require('selenium-webdriver');
const delay = (ms) => {
return new Promise((resolve) => {
setTimeout(resolve, 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 = await driver.findElement(selection);
element.sendKeys('matt.huntington@generalassemb.ly');
selection = selenium.By.id('baseForm');
element = await driver.findElement(selection);
element.submit();
await delay(2000);
selection= selenium.By.css('input[type="text"]');
element = await driver.findElement(selection);
element.sendKeys('matt.huntington@generalassemb.ly');
selection= selenium.By.css('input[type="password"]');
element = await driver.findElement(selection);
element.sendKeys('Hunt!ngt0n80!');
selection = selenium.By.css('form');
element = await driver.findElement(selection);
element.submit();
await delay(2000);
selection= selenium.By.css('a')
let elements = await driver.findElements(selection);
elements[1].click();
}
const search = async () => {
let selection = selenium.By.id('program');
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 = await driver.findElement(selection);
select = new selenium.Select(element);
await select.selectByVisibleText('Online');
selection = selenium.By.id('from');
element = await driver.findElement(selection);
element.sendKeys('01/01/2021');
selection = selenium.By.id('filter-form');
element = await driver.findElement(selection);
element.submit();
}
const main = async () => {
await login();
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()