Created
February 26, 2020 11:40
-
-
Save AlexanderMoskovkin/2197aceec9cfb01a95f3cb808d731f81 to your computer and use it in GitHub Desktop.
TestCafe Studio Roles using (Case 1)
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
var tc = require('testcafe'); | |
var Role = tc.Role; | |
var Selector = tc.Selector; | |
var RoleHelper = require('./role-helper-1'); | |
await t.useRole(RoleHelper.getEmptyRole(Selector, Role)); |
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
run in recording - works OK | |
run from testcafe console - works OK | |
run from TestCafe Studio play button - An unhandled error occurred in the custom script: | |
The "role" argument is expected to be a Role instance, but it was object. |
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
{"fixtures":[{"name":"Roles Demo","pageUrl":"https://reportse2e.iszolea.net/","tests":[{"name":"Case 1","commands":[{"callsite":"0","expression":"var tc = require('testcafe');\r\nvar Role = tc.Role;\r\nvar Selector = tc.Selector;\r\n\r\nvar RoleHelper = require('./role-helper-1');\r\n\r\nawait t.useRole(RoleHelper.getEmptyRole(Selector, Role));","studio":{},"type":"execute-async-expression"}]}]}]} |
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
var useRole = async (Selector, t, login, password) => { | |
await t | |
.click(Selector('span').withText('SIGN IN')) | |
.typeText(Selector('.login-form').find('[name="Username"]'), login) | |
.typeText(Selector('.login-form').find('[name="Password"]'), password) | |
.click(Selector('span').withText('Login')); | |
} | |
module.exports.getEmptyRole = (Selector, Role) => { | |
var role = Role('https://reportse2e.iszolea.net/', async t => { | |
await useRole(Selector, t, 'E2EUserEmpty', 'E2EUserEmpty!'); | |
}); | |
return role; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTES:
Case1.testcafe
- test with only one step. It's a script step. I'm trying to call UseRole inside that step. I keep the Role object in a separated file (role-helper-1.js
).You can see the code of this step in the
case1 - script step.txt
You can try to run it in three ways (from studio via recording and via play button and from console testcafe app). Results of running are in the
case1 results.txt
. So the problem it works in two cases but doesnt work in the third