forked from DevExpress/testcafe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass options to derivative selectors (fixes DevExpress#1907)
- Loading branch information
1 parent
edc8b48
commit 2f85f34
Showing
4 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test/functional/fixtures/regression/gh-1907/pages/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>gh-1907</title> | ||
</head> | ||
<body> | ||
<div></div> | ||
<div id="div">div | ||
<div id="child">child</div> | ||
</div> | ||
<div></div> | ||
|
||
<div id="delay" style="display: none;">Appears after delay</div> | ||
<div id="hidden" style="display: none">Hidden</div> | ||
|
||
<script> | ||
window.setTimeout(function (){ | ||
document.querySelector('#delay').style.display = 'block'; | ||
}, 1000); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var expect = require('chai').expect; | ||
|
||
describe('[Regression](GH-1907)', function () { | ||
it('Base selector should pass the boundTestRun option to derivative selectors', function () { | ||
return runTests('testcafe-fixtures/index-test.js', 'Check boundTestRun'); | ||
}); | ||
|
||
it('Base selector should pass timeout and visibilityCheck options to derivative selectors', function () { | ||
return runTests('testcafe-fixtures/index-test.js', 'Check timeout and visibilityCheck', { | ||
selectorTimeout: 0, | ||
shouldFail: true | ||
}) | ||
.catch(function (errs) { | ||
expect(errs[0]).contains('Cannot obtain information about the node because the specified selector does not match any node in the DOM tree.'); | ||
expect(errs[0]).contains('> 40 | await t.expect(div.textContent).eql(\'Hidden\');'); | ||
}); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
test/functional/fixtures/regression/gh-1907/testcafe-fixtures/index-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import fs from 'fs'; | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `GH-1907` | ||
.page `http://localhost:3000/fixtures/regression/gh-1907/pages/index.html`; | ||
|
||
test('Check boundTestRun', async t => { | ||
const div = Selector('#div', { boundTestRun: t }); | ||
|
||
return new Promise((resolve, reject) => { | ||
fs.readFile('not/exists', async () => { | ||
try { | ||
await t | ||
.expect(div.nth(0).exists).ok() | ||
.expect(div.withText('div').exists).ok() | ||
.expect(div.withAttribute('id', 'div').exists).ok() | ||
.expect(div.filter(() => true).exists).ok() | ||
.expect(div.find('#child').exists).ok() | ||
.expect(div.parent().exists).ok() | ||
.expect(div.child().exists).ok() | ||
.expect(div.sibling().exists).ok() | ||
.expect(div.nextSibling().exists).ok() | ||
.expect(div.prevSibling().exists).ok(); | ||
} | ||
catch (err) { | ||
reject(err); | ||
return; | ||
} | ||
|
||
resolve(); | ||
}); | ||
}); | ||
}); | ||
|
||
test('Check timeout and visibilityCheck', async t => { | ||
await t.click(Selector('#delay', { timeout: 2000 }).withText('Appears after delay')); | ||
|
||
const div = Selector('#hidden', { visibilityCheck: true }).withText('Hidden'); | ||
|
||
await t.expect(div.textContent).eql('Hidden'); | ||
}); |