简体   繁体   中英

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

We're using Selenium 2 with Java in our test automation process. 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.

Is there any (easy) way to simulate a lost connection in Java or directly in Selenium?

Yes, you can. I'm using Vaurien , the chaos TCP proxy to simulate network problems.

According to the documentation, an example to add 20% delay of all HTTP requests:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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