forked from vip-git/universal-json-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowserstack.js
67 lines (58 loc) · 1.76 KB
/
browserstack.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
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable no-undef */
const assert = require('assert');
const { Builder, By, until } = require('selenium-webdriver');
// Input capabilities
const capabilities = {
'browserName': 'Chrome',
'browser_version': '79.0',
'os': 'Windows',
'os_version': '10',
'resolution': '1024x768',
'build': 'mocha-browserstack',
'browserstack.user': 'bsuser10422',
'browserstack.key': 'cmffipt5pwL4c5QyRwji',
'name': 'React JSON Schema Form - Material UI',
};
const buildDriver = (caps) => new Builder()
.usingServer('https://hub-cloud.browserstack.com/wd/hub')
.withCapabilities(caps)
.build();
describe('Testing forms', () => {
let driver;
beforeEach((done) => {
driver = buildDriver(capabilities);
done();
});
it('can load the initial page', async () => {
await driver.get('https://react-jsonschema-form-material-ui.github56.now.sh');
const autocomplete = await driver.findElement(
By.xpath("//input[@value='Chuck']"),
);
autocomplete.sendKeys('BrowserStack');
// // Wait unti pac-item item appears
// await driver.wait(
// until.elementLocated(
// By.className('pac-item'),
// ),
// 10000,
// );
const autocompleteResult = await driver.findElement(
By.xpath('//button[2]'),
);
autocompleteResult.click();
// Or using sleep
// Wait for 3 seconds
await driver.sleep(3000);
// assertion codes...
const newName = await driver
.findElement(By.xpath("//input[@value='ChuckBrowserStack']"))
.getAttribute('value');
// Cannot assert because the value doesn't appear in the DOM
assert.equal(newName, 'ChuckBrowserStack');
});
afterEach((done) => {
driver.quit();
done();
});
});