-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathkeysTest.spec.js
69 lines (51 loc) · 1.97 KB
/
keysTest.spec.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
const {By, Key} = require('selenium-webdriver');
const {suite} = require('selenium-webdriver/testing');
const assert = require("assert");
suite(function(env) {
describe('Keyboard Action - Keys test', function() {
let driver;
before(async function() {
driver = await env.builder().build();
});
after(() => driver.quit());
it('KeyDown', async function() {
await driver.get('https://www.selenium.dev/selenium/web/single_text_input.html');
await driver.actions()
.keyDown(Key.SHIFT)
.sendKeys('a')
.perform();
const textField = driver.findElement(By.id("textInput"));
assert.deepStrictEqual('A', await textField.getAttribute('value'))
});
it('KeyUp', async function() {
await driver.get('https://www.selenium.dev/selenium/web/single_text_input.html');
const textField = driver.findElement(By.id("textInput"));
await textField.click();
await driver.actions()
.keyDown(Key.SHIFT)
.sendKeys('a')
.keyUp(Key.SHIFT)
.sendKeys("b")
.perform();
assert.deepStrictEqual('Ab', await textField.getAttribute('value'))
});
it('sendKeys', async function() {
await driver.get('https://www.selenium.dev/selenium/web/single_text_input.html');
const textField = driver.findElement(By.id("textInput"));
await textField.click();
await driver.actions()
.sendKeys('abc')
.perform();
assert.deepStrictEqual('abc', await textField.getAttribute('value'))
});
it.skip('Designated Element', async function() {
await driver.get('https://www.selenium.dev/selenium/web/single_text_input.html');
await driver.findElement(By.tagName("body")).click();
const textField = await driver.findElement(By.id("textInput"));
await driver.actions()
.sendKeys(textField, 'Selenium!')
.perform();
assert.deepStrictEqual('Selenium!', await textField.getAttribute('value'))
});
});
});