-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathforms.js
More file actions
30 lines (24 loc) · 962 Bytes
/
forms.js
File metadata and controls
30 lines (24 loc) · 962 Bytes
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
const {client} = require('nightwatch-cucumber');
const {defineSupportCode} = require('cucumber');
defineSupportCode(({When}) => {
When(/^I fill in "([^"]*)" with "([^"]*)"$/, (input, text) => {
return client.setValue('input[name="' + input + '"]', text);
});
When(/^I fill in "([^"]*)" with "([^"]*)" in form "([^"]*)"$/, (input, text, form) => {
return client.setValue('form[name="' + form + '"] input[name="' + input + '"]', text);
});
When(/^I submit "([^"]*)"$/, (form) => {
const element = 'form[name="' + form + '"] button[type="submit"]';
return client
.useCss()
.waitForElementVisible(element)
.click(element);
});
When(/^I check "([^"]*)"$/, (label) => {
const element = '//label[contains(., "' + label + '")]';
return client
.useXpath()
.waitForElementVisible(element)
.click(element);
});
});