forked from lalit10/SimplyClip
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathseleniumTest.js
117 lines (88 loc) · 4.09 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
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);
});