-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute.js
46 lines (38 loc) · 2.09 KB
/
execute.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const { Builder, By, Key } = require("selenium-webdriver");
const chrome = require('selenium-webdriver/chrome');
const options = new chrome.Options();
options.excludeSwitches(['enable-logging']);
module.exports = async ({ usr, pwd }) => {
const driver = await new Builder().forBrowser("chrome").setChromeOptions(options).build();
await driver.get('https://sql.cankaya.edu.tr/Evaluation');
const usernameInput = (await driver.findElements(By.id("UserName")))[0];
await driver.executeScript("arguments[0].scrollIntoView(true);", usernameInput);
await usernameInput?.click();
await usernameInput?.sendKeys(usr);
const passwordInput = (await driver.findElements(By.id("Password")))[0];
await driver.executeScript("arguments[0].scrollIntoView(true);", passwordInput);
await passwordInput?.click();
await passwordInput?.sendKeys(pwd);
await driver.sleep(1000);
const submitButton = (await driver.findElements(By.className("btn btn-primary btn-block btn-flat")))[0];
await driver.executeScript("arguments[0].scrollIntoView(true);", submitButton);
await submitButton?.click();
const surveys = await driver.findElements(By.className("btn btn-info"));
for (let i = 0; i < surveys.length; i++) {
const survey = (await driver.findElements(By.className("btn btn-info")))[i];
await driver.executeScript("arguments[0].scrollIntoView(true);", survey);
await survey?.click();
const rows = await driver.findElements(By.className("table table-responsive"));
await Promise.all(rows.map(async (row) => {
const rowText = await row.getText();
if (rowText.includes("0 1 2 3 4 5")) {
let five = await row.findElement(By.css("input[value='5']"));
await driver.executeScript("arguments[0].scrollIntoView(true);", five);
await five?.click();
}
}));
const sendSurvey = (await driver.findElements(By.id("submitButton")))[0];
await driver.executeScript("arguments[0].scrollIntoView(true);", sendSurvey);
await sendSurvey?.click();
}
}