forked from Createdd/seleniumExample
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
85 lines (74 loc) · 1.91 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const cred = require('./cred');
var promise = require('selenium-webdriver').promise;
//setup
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder().forBrowser('chrome').build();
driver.manage().window().maximize();
//click function
var clickingAll = () => {
driver
.findElements(
webdriver.By.xpath('//i[@class="icon-s icon-checkbox pseudocheckbox "]')
)
.then(elements => {
elements.map(elem => {
elem.getAttribute('aria-checked').then(check => {
if (check === 'true') {
elem.click();
}
});
});
});
driver
.findElement(webdriver.By.xpath('//select[@class="j-selectbox"]'))
.click();
driver
.findElement(webdriver.By.xpath('//option[@value="NO_RECEIVE"]'))
.click();
try {
driver
.findElement(webdriver.By.xpath('//option[@value="OFF]'))
.then(null, err => {
if (err) {
return false;
}
})
.click();
} catch (e) {
return false;
}
driver.navigate().back();
};
//actions
driver.get('https://secure.meetup.com/login/');
var mail = driver.findElement(webdriver.By.id('email'));
var pass = driver.findElement(webdriver.By.id('password'));
mail.sendKeys(cred.cred.user);
pass.sendKeys(cred.cred.pass);
driver.findElement(webdriver.By.name('submitButton')).click();
driver
.findElement(
webdriver.By.className(
'valign--middle display--none atMedium_display--inline'
)
)
.click();
driver.findElement(webdriver.By.xpath('//a[text()="Settings"]')).click();
driver.findElement(webdriver.By.xpath('//a[text()="Email Updates"]')).click();
const list = driver.findElements(
webdriver.By.xpath('//li[@class="list-item"]/a')
);
list.then(function(elements) {
var links = elements.map(elem => {
return elem.getAttribute('href');
});
promise.all(links).then(linkRefs => {
linkRefs.forEach(element => {
driver.navigate().to(element);
clickingAll();
});
});
});
driver.quit();