-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathBrowserStackSample.js
More file actions
50 lines (50 loc) · 1.7 KB
/
Copy pathBrowserStackSample.js
File metadata and controls
50 lines (50 loc) · 1.7 KB
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
let wd = require('wd');
let assert = require('assert');
let asserters = wd.asserters;
desiredCaps = {
// Set your BrowserStack access credentials
'browserstack.user' : 'bayurizkhy_snQWko',
'browserstack.key' : 'WZ4xpkZvnNREsUkUH8Wt',
// Set app_url of the application under test
'app' : 'bs://df7671264546324fac5df2c770de1cfb6a3c1418',
// Specify device and os_version for testing
'device' : 'Samsung Galaxy A11',
'os_version' : '10.0',
// Set other BrowserStack capabilities
'project' : 'First NodeJS project',
'build' : 'browserstack-build-1',
'name': 'first_test'
};
// Initialize the remote Webdriver using BrowserStack remote URL
// and desired capabilities defined above
driver = wd.promiseRemote("http://hub-cloud.browserstack.com/wd/hub");
// Test case for the BrowserStack sample Android app.
// If you have uploaded your app, update the test case here.
driver.init(desiredCaps)
.then(function () {
return driver.waitForElementByAccessibilityId(
'Search Wikipedia', asserters.isDisplayed
&& asserters.isEnabled, 30000);
})
.then(function (searchElement) {
return searchElement.click();
})
.then(function () {
return driver.waitForElementById(
'org.wikipedia.alpha:id/search_src_text', asserters.isDisplayed
&& asserters.isEnabled, 30000);
})
.then(function (searchInput) {
return searchInput.sendKeys("BrowserStack");
})
.then(function () {
return driver.elementsByClassName('android.widget.TextView');
})
.then(function (search_results) {
assert(search_results.length > 0);
})
.fin(function() {
// Invoke driver.quit() after the test is done to indicate that the test is completed.
return driver.quit();
})
.done();