-
-
Save NickCis/1ca33e22641c9d6dda1fc88c4de49c3a to your computer and use it in GitHub Desktop.
Testcafe bug: ignores setNativeHandler on useRole first redirection
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
<html> | |
<head> | |
<title>My Nice Page</title> | |
</head> | |
<body> | |
<h1>My nice body :)</h1> | |
<p>This is a nice webpage</p> | |
<script> | |
window.addEventListener('beforeunload', function() { | |
console.log('beforeunload'); | |
return 'something'; | |
}); | |
</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
<html> | |
<head> | |
<title>My Nice Login</title> | |
</head> | |
<body> | |
<h1>Login :)</h1> | |
<p>This is a nice Login</p> | |
<form action="index.html"> | |
<input name="user" type="text" id="user" /> | |
<input name="password" type="password" id="password" /> | |
<button type="submit" id="submit">Send</button> | |
</form> | |
</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
{ | |
"name": "testcafe-setNativeHandler-userRole-bug", | |
"version": "0.0.1", | |
"main": "index.js", | |
"license": "MIT", | |
"dependencies": { | |
"http-server": "^0.11.1", | |
"testcafe": "^0.22.0" | |
}, | |
"scripts": { | |
"start": "http-server", | |
"test": "testcafe chromium test.js --app 'npm start'" | |
} | |
} |
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
import { Role, Selector } from 'testcafe'; | |
const url = 'http://localhost:8080'; | |
const user = new Role(`${url}/login.html`, async t => { | |
await t | |
.typeText('#user', 'user') | |
.typeText('#password', 'password') | |
.click('#submit'); | |
}); | |
fixture('Home') | |
.page(url); | |
test('My first test', async t => { | |
await t | |
.setNativeDialogHandler((...args) => { | |
console.log('handler', args); | |
return true; | |
}) | |
.useRole(user); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment