forked from umagnanasundaram2128/SimplyClip
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathseleniumTest.js
207 lines (156 loc) · 6.99 KB
/
seleniumTest.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
const assert = require('assert');
let webdriver = require("selenium-webdriver");
let chrome = require("selenium-webdriver/chrome");
const {Key,
By} = require("selenium-webdriver");
describe('Verify setup with Google Search',function() {
it('browser should open', async function () {
// Open the Chrome Browser with a custom profile
const options = new chrome.Options()
.addArguments('--user-data-dir=/Users/nehakotcherlakota/Desktop');
// Initialise driver to launch Chrome
const driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
// Launch Google.com
driver.get('http://google.com');
// Search for abc in the searchbox in Chrome and Press Enter
const searchBox = driver.findElement(webdriver.By.name('q'));
searchBox.sendKeys('abc', Key.RETURN);
// Check if the value in the searchbox is equal to the value you entered
searchBox.getAttribute('value').then(function(value) {
assert.equal(value, 'abc');
});
// Close the browser
driver.close();
// Quit the browser
driver.quit();
});
});
describe('Check browser copy functionality',function() {
it('text should be copied', async function () {
// Open the Chrome Browser with a custom profile
const options = new chrome.Options()
.addArguments('--user-data-dir=/Users/nehakotcherlakota/Desktop');
// Initialise driver to launch Chrome
const driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
// Launch Google.com
driver.get('http://google.com');
// Search for abc in the searchbox in Chrome and Press Enter
const searchBox = driver.findElement(webdriver.By.name('q'));
searchBox.sendKeys('hello', Key.RETURN);
// Store the text in the first div in the search results page
let results = driver.findElement(By.xpath("html/body/div[1]/div[5]/div[4]/div[5]/div[1]/div[1]/div/div/div"));
// Check if the value is stored
results.getAttribute('value').then(function(value) {
assert.equal(value, results.getText());
});
// Close the browser
driver.close();
// Quit the browser
driver.quit();
}).timeout(10000);
});
describe('Check simply clip functionality',function() {
it('copied text should exist in SimplyClip clipboard', async function () {
// Open the Chrome Browser with a custom profile
const options = new chrome.Options()
.addArguments('--user-data-dir=/Users/nehakotcherlakota/Desktop');
// Initialise driver to launch Chrome
const driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
// Launch Google.com
driver.get('http://google.com');
// Search for abc in the searchbox in Chrome and Press Enter
const searchBox = driver.findElement(webdriver.By.name('q'));
searchBox.sendKeys('hello', Key.RETURN);
// Store the text in the first div in the search results page
let results = driver.findElement(By.xpath("html/body/div[1]/div[5]/div[4]/div[5]/div[1]/div[1]/div/div/div"));
//Execute the Command+C command to copy the text in the first div in the search results page
results.sendKeys(Key.COMMAND, 'c');
//Retrieve the result from the clipboard list in the extension
let clipboard_result = driver.findElement(By.className("clipboard_list"));
//Check if the copied value exists in the clipboard list of the extension
clipboard_result.getAttribute('value').then(function(value) {
assert.equal(value, results.getText());
});
// Close the browser
driver.close();
// Quit the browser
driver.quit();
}).timeout(10000);
});
describe('Check dark mode functionality',function() {
it('copied text should exist in SimplyClip clipboard', async function () {
// Open the Chrome Browser with a custom profile
const options = new chrome.Options()
.addArguments('--user-data-dir=/Users/nehakotcherlakota/Desktop');
// Initialise driver to launch Chrome
const driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
// Launch Google.com
driver.get('http://google.com');
// Search for dark mode button and click on it
const dark_mode = driver.findElement(By.xpath("/html/body/div[1]/label[2]/span"));
dark_mode.sendKeys(Key.RETURN);
dark_mode.click();
// Close the browser
driver.close();
// Quit the browser
driver.quit();
}).timeout(10000);
});
describe('Check sorting functionality',function() {
it('copied text should exist in SimplyClip clipboard', async function () {
// Open the Chrome Browser with a custom profile
const options = new chrome.Options()
.addArguments('--user-data-dir=/Users/nehakotcherlakota/Desktop');
// Initialise driver to launch Chrome
const driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
// Launch Google.com
driver.get('http://google.com');
// Search for prioty down button
const priority_down = driver.findElement(By.xpath("/html/body/ul/li[1]/div/div[5]/img"));
priority_down.click();
// Close the browser
driver.close();
// Quit the browser
driver.quit();
}).timeout(10000);
});
describe('Check Merge functionality',function() {
it('copied text should exist in SimplyClip clipboard', async function () {
// Open the Chrome Browser with a custom profile
const options = new chrome.Options()
.addArguments('--user-data-dir=/Users/nehakotcherlakota/Desktop');
// Initialise driver to launch Chrome
const driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
// Launch Google.com
driver.get('http://google.com');
const checkbx1 = driver.findElement(By.xpath("/html/body/ul/li[1]/div/input"));
checkbx1.click();
const checkbx2 = driver.findElement(By.xpath("/html/body/ul/li[2]/div/input"));
checkbx2.click();
// Search for merge button
const merge = driver.findElement(By.xpath("/html/body/div[1]/div[2]/img"));
merge.click();
// Close the browser
driver.close();
// Quit the browser
driver.quit();
}).timeout(10000);
});