Fixture.before hook 中的错误 TypeError: t.maximizeWindow 不是函数 TestCafe
我想在一个网站上做一些测试,任务在登录后执行。所以我创建了一个用于登录的角色,并在 beforeEach 方法中调用它。运行测试时,登录功能在每次测试之前发生。但我不想发生这种情况,然后我将角色和最大化窗口函数移至 before 方法中。现在它给出了一个错误fixture.before hook 中出现错误 TypeError: t.maximizeWindow 不是函数
即使我删除了maximizeWindow函数然后运行,它也会显示错误fixture.before hook 中出现错误 TypeError: t.useRole 不是函数
任何人都可以帮忙吗?
I want to do some tests on a website which the tasks come after login. So I created a role for login and call it in beforeEach method. When running tests, the login function happens before every test. But I didn't want to happen that and then I moved the role and maximize window function into the before method. Now it gives an errorError in fixture.before hook TypeError: t.maximizeWindow is not a function
Even if I removed the maximizeWindow function and then run, it shows errorError in fixture.before hook TypeError: t.useRole is not a function
Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能在
before
夹具内使用t.maximizeWindow
和其他t
方法。before
和after
固定装置挂钩在固定装置内容之前或之后运行。他们无法访问浏览器。请查看 https://testcafe.io/ Documentation/403435/guides/advanced-guides/hooks#fixture-hooks 文章了解更多详细信息
You cannot use
t.maximizeWindow
and othert
methods inside thebefore
fixture. Thebefore
andafter
fixture hooks run before or after the content of the fixture. They cannot access the browser.Please take a look at the https://testcafe.io/documentation/403435/guides/advanced-guides/hooks#fixture-hooks article for more details
如果您不希望在固定装置中的每个测试中使用角色,您可以简单地在测试主体中添加 t.useRole 方法,而无需任何挂钩。
另请注意,当您在
beforeEach
挂钩中使用 Roles 机制时,登录进程仅在第一次运行。对于其余的测试,您将自动登录。If you do not wish to use roles for every test in fixture you can simply add the
t.useRole
method inside the test body without any hooks.Please also note that when you are using the Roles mechanism in the
beforeEach
hook, the login process runs only for the first time. For the remaining tests you will be automatically logged in.