简体   繁体   English

空手道 UI 测试:如何防止浏览器在场景结束时关闭

[英]Karate UI testing: how to prevent browser closing at the end of Scenario

I am working on UI automated tests using Karate framework.我正在使用 Karate 框架进行 UI 自动化测试。 I am really enjoyng working with this great tool, but it's something that I'm trying to resolve for a while and can't find any solution.我真的很喜欢使用这个很棒的工具,但这是我试图解决一段时间但找不到任何解决方案的问题。

I have a feature file with 3 scenarios and I want to open the browser and to make login only once , before all scenarios, and to be closed only after the last scenario is finished.我有一个包含3 个场景的功能文件,我想打开浏览器并在所有场景之前只登录一次,并且仅在最后一个场景完成后关闭。 In my case driver is started at separated login.feature file which is called from Background using 'callonce read('login.feature')' command.在我的例子中,驱动程序是在单独的 login.feature 文件中启动的,该文件是使用“callonce read('login.feature')”命令从后台调用的。 I've seen somewhere that if driver is started before scenario.我在某处看到,如果驱动程序在场景之前启动。 In my case it's not working.就我而言,它不起作用。 What do I do wrong?我做错了什么?

You can use this answer as a reference: https://stackoverflow.com/a/60581024/143475您可以使用此答案作为参考: https://stackoverflow.com/a/60581024/143475

So it is supposed to work if you create a feature and then call the other scenarios from that feature.因此,如果您创建一个功能然后从该功能调用其他场景,它应该可以工作。 Karate is designed to close the driver after a Scenario by default.空手道旨在默认情况下在Scenario后关闭驱动程序。

I also recommend that when you have a flow, don't try to split it into different Scenarios.我还建议当你有一个流程时,不要试图把它分成不同的场景。 Or you should be prepared to call different features from one Scenario.或者您应该准备好从一个场景中调用不同的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 空手道API测试-如何遍历读取多个json文件以用作单个场景的请求? - Karate API Testing- how to iterate over reading multiple json files to be used as request for a single scenario? 空手道 - 如何以特定分辨率运行浏览器 (Firefox) - Karate - how to run browser (Firefox) in specific resolution 如何使用 Karate UI Automation 在基于 yaml 的 UI 上输入值 - How to enter a value on yaml based UI using Karate UI Automation 在Selenium自动端2端测试期间关闭浏览器 - Closing browser during selenium automated end 2 end tests 如何使用空手道框架自动测试 razorpay sdk 调用? - How to automate the testing of razorpay sdk calls using karate framework? "空手道 UI 自动化" - Karate Ui automation 如何使用 Karate UI 在 chrome 中查看打印模式 - How can I view the print modal in chrome with Karate UI 空手道 UI 自动化 - 如何关闭位置津贴 window (Chrome) - Karate-UI Automation - How to close Location allowance window (Chrome) 开发人员可以做些什么来使浏览器易于自动化测试? - What can developers do to make the browser ui easy to automate for testing? 如何使用空手道 UI 将文件下载到特定位置我需要将文件保存到自定义位置而不是下载 - How to download file to a specific location using Karate UI I need a file to be saved to customized location not in downloads
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM