简体   繁体   English

如何模拟与Java / Selenium的连接断开?

[英]How can I simulate a lost connection with java/selenium?

We're using Selenium 2 with Java in our test automation process. 我们在测试自动化过程中使用带有Java的Selenium 2。 Our web application periodically polls for new information - if it can't connect to the server (ie. server down, cable unplugged, ...), a popup should appear. 我们的Web应用程序会定期轮询以获取新信息-如果它无法连接到服务器(例如,服务器关闭,电缆拔出等),则会出现一个弹出窗口。

Is there any (easy) way to simulate a lost connection in Java or directly in Selenium? 有没有什么简单的方法可以模拟Java或直接在Selenium中丢失的连接?

Yes, you can. 是的你可以。 I'm using Vaurien , the chaos TCP proxy to simulate network problems. 我正在使用Vaurien (混乱的TCP代理)来模拟网络问题。

According to the documentation, an example to add 20% delay of all HTTP requests: 根据文档,此示例将所有HTTP请求的延迟增加20%:

vaurien --protocol http --proxy localhost:8000 --backend google.com:80 --behavior 20:delay

You can find all "behaviors" here: http://vaurien.readthedocs.org/en/1.8/behaviors.html In my opinion, hang behavior can be useful for you. 您可以在此处找到所有“行为”: http : //vaurien.readthedocs.org/en/1.8/behaviors.html在我看来, hang行为可能对您有用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM