你可以在 Vaadin 14.10.0 上如何禁用 Live Reload Widget?

huangapple go评论63阅读模式
英文:

How can I disable the Live Reload Widget on Vaadin 14.10.0?

问题

I have a Spring Boot application that I run with the Spring Developer Tools disabled (spring.devtools.restart.enabled=false in my application.properties) for running my automated Selenium tests against it. However, the Vaadin Live Reload Widget still appears and obscures UI elements, which I need to access in my Selenium tests.

我有一个Spring Boot应用程序,我使用Spring开发者工具禁用(在我的application.properties中设置spring.devtools.restart.enabled=false)来运行我的自动化Selenium测试。然而,Vaadin Live Reload Widget仍然出现并遮挡了我在Selenium测试中需要访问的UI元素。

I have tried to put vaadin.devmode.devTools.enabled=false in my application.properties and also to run my application with -Dvaadin.devmode.devTools.enabled=false, but to no avail. So how can I get rid of this widget entirely, short of running Vaadin in production mode?

我尝试将vaadin.devmode.devTools.enabled=false放入我的application.properties中,并尝试使用-Dvaadin.devmode.devTools.enabled=false运行我的应用程序,但都没有成功。那么,除了将Vaadin运行在生产模式下之外,我如何完全摆脱这个小部件呢?

FWIW, this is the error message I get in my UI test, which seems to confirm that the widget is in the way:

顺便说一下,这是我在UI测试中收到的错误消息,似乎证实了这个小部件的存在:

Element <vaadin-button class="save-button" theme="primary" tabindex="0" role="button">...</vaadin-button> is not clickable at point (1857, 953). Other element would receive the click: <vaadin-devmode-gizmo url="./vaadinServlet/" backend="SPRING_BOOT_DEVTOOLS" springbootlivereloadport="35729"></vaadin-devmode-gizmo>

英文:

I have a Spring Boot application that I run with the Spring Developer Tools disabled (spring.devtools.restart.enabled=false in my application.properties) for running my automated Selenium tests against it. However, the Vaadin Live Reload Widget still appears and obscures UI elements, which I need to access in my Selenium tests.

I have tried to put vaadin.devmode.devTools.enabled=false in my application.properties and also to run my application with -Dvaadin.devmode.devTools.enabled=false, but to no avail. So how can I get rid of this widget entirely, short of running Vaadin in production mode?

FWIW, this is the error message I get in my UI test, which seems to confirm that the widget is in the way:

Element <vaadin-button class="save-button" theme="primary" tabindex="0" role="button">...</vaadin-button> is not clickable at point (1857, 953). Other element would receive the click: <vaadin-devmode-gizmo url="./vaadinServlet/" backend="SPRING_BOOT_DEVTOOLS" springbootlivereloadport="35729"></vaadin-devmode-gizmo>

答案1

得分: 2

最佳解决方案通常是在生产模式下运行服务器。然后,您可以测试您的用户正在使用的内容,而不需要额外的工具。作为一个额外的好处,这可能会更快,因为JS捆绑包在服务器启动时只编译一次,而不是在每个浏览器实例中单独编译用于测试的情况下。

如果您确实希望以开发模式运行以在本地运行测试,那么一个好的解决方案是在测试中注入一个CSS片段,以隐藏开发工具,例如vaadin-dev-tools {display:none;}。这可以通过测试本身或者例如使用应用程序的查询参数来完成。如果以这种方式操作,您不必在开发和运行测试之间重新启动服务器。

参数也应该起作用,但我在使用它时看不到任何效果。还有一个问题,关于移除禁用参数,因为一些开发模式功能依赖于存在开发工具窗口:https://github.com/vaadin/flow/issues/16329

英文:

The best solution is typically to run the server in production mode. Then you are testing what your users are using and you do not have any extra tools. As a bonus, it might be faster as the JS bundle is compiled once on server startup and not separately for each browser instance used in the tests

If you do want to run in development mode to run tests locally, then a good solution can be to inject a CSS snippet in the test that hides the dev tools, like vaadin-dev-tools {display:none;}. This could be done either from the test itself or e.g. using a query parameter to the application. If you do it this way, you do not have to restart the server between development and running tests.

The parameter is supposed to work also but I cannot see any effect when using it. There is also an issue about removing the disabling parameter as some development mode functionality relies on the dev tools window being there: https://github.com/vaadin/flow/issues/16329

huangapple
  • 本文由 发表于 2023年5月25日 17:36:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76330857.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定