Running the Selenium Web Driver execution at low speed - junit

How to run the Selenium WebDriver at slow speed by using Junit framework.
tried using
wait( );
but can't succeed.
can I use wait(); or Is there any other method?
Please suggest me.

WebDriver used to have a #setSpeed()-method, but it seems to have been removed.
You should be able to wrap your WebDriver in a EventFiringWebDriver and do a Thread.sleep() for the events you want to slow down.
EventFiringWebDriver eventFiringWebDriver = new EventFiringWebDriver(yourWebDriver);
eventFiringWebDriver.register(new WebDriverEventListener() {
// Implement bunch of methods
}
Using Thread.sleep() seems like a bit of a hack to me though. Are there no other ways of achieving your goal other than slowing down your tests?
There are also tools that lets you emulate low-bandwidth (slow) network connections. Running your Selenium-test through these should also decrease your speed.
ip_relay proxies your connection:
$ iprelay -b2500 8000:localhost:80
http://localhost:8000 will proxy your connection to http://localhost:80 and slow it down.
Traffic Control (tc) lets you do something similiar.

Related

Monitoring headless Chrome

I'm using Chrome in headless mode via CDP (Chrome devtools protocol) to do HTML to PDF conversions. Works well but I do not trust Chrome to run forever and want to build a guardian service to monitor its responsiveness and if necessary kill the process and relaunch it.
What would be a good indicator of health? What I'm looking for is a low overhead test I can perform at fairly frequent intervals so that the restart latency is minimised.
I could try to perform some kind of CDP command if anyone has a suggestion and a reliable way to determine success.
I can't think of anything else, that's why I've thrown it open for suggestions.
My best suggestion for this case is to use the Target domain. Listening to some of the events that are fired from the target domain will give you some information regarding the state of your browser, such as TargetCrashed.
On top of that, you could use basic domains like Runtime (provides the evaluate method), SystemInfo or Browser to send the browser requests in order to check its health.

Avoid smartcards using puppeteer

When I run unit tests with puppeteer, my smartcard (observed with a YubiKey or Nitrokey) gets accessed; you can see the light blink. I am using that smart card in my host system, but do not want to access it from puppeteer.
This slows down the tests, and is not desirable in general; the tests should certainly not use my smartcard.
How can I prevent puppeteer/chromium from accessing smartcards? I am fine with a Linux-only solution.

Building web server using chrome.socket API

I've built a web server using Chrome Packaged Apps. The problem I see repeatedly is that chrome.socket.accept() and chrome.socket.write() don't invoke their callback functions. It usually works more or less reliably if request rate is less than 1 request per seconds. If I go above that, then I start seeing errors or missing callbacks.
I did similar tests with sample "webserver" app build by Google (https://github.com/GoogleChrome/chrome-app-samples/tree/master/webserver). It has the same problem. It usually takes less than 100 requests before web server stops responding. The easiest way to reproduce the problem is to use Chrome browser as a client and hold F5 key for few seconds.
It would be desirable to have a sample app that demonstrates how to build reliable web server using chrome.socket. So far I tried several different workarounds for monitoring the situation from the app itself and restarting socket when socket stops working, but it's not easy because there is no reliable way to check the status of the connection or status of the last operation when callback is not fired. I tried to use getInfo() method, but it always returns "connected=true" regardless of the situation.
I saw this on Windows 7 and Chrome OS (Chromebook).
Just an update on this. According to this the issue is now fixed.
There are still other problems with the sample web server application. I noticed that I could make the sample app lock up by holding down Ctrl-R in the browser. I wrote a more robust one that you can use here: https://github.com/kzahel/web-server-chrome

How do I simulate latency and other network disturbances between client and server on same PC

I built simple server-client application (windows) using Adobe AIR, based on UDP protocol. What I want to achieve is to test how my application works under network disturbances (latency, packet loss, packet reordering) on a SINGLE PC.
There is plenty of programs for network disturbance simulation, but it looks like they're all made to simulate network disturbances between two PCs, which is not what I need.
If you are using windows, it's not quite possible to create some delay in localhost latency. I came up to this issue this winter and that's how I solved a problem.
All latency logic will be in your AS3 code. On the moment you receive some data (socket data progress event), you create a new Timer with desired delay (or use an existing one) and pass received socket data with the Timer.COMPLETE event. When your timer fires, you can use it's data like you'd normally do without it - you call some needed functions, you process it and do whatever you need. You can also use setTimeout instead of Timer, it doesn't really matter. You can also add some random packet loss by not creating a Timer, so no data would pass through. And you can also use random Timer time so some packets will be reordered.
I won't write any code because the implementation really depends on what you already have now. But I hope this little hint will help you :)

How can I run teardown code when the Flash VM closes?

Is there a way to register code to be run when Flash is about to close (e.g., when the user closes the browser or when DOM manipulation causes the embedded player to be removed)?
In particular, I'd like for my application to send a closing packet to a remote service so the user's peers know that the user has no chance of coming back without having to wait for a timeout. I'm using URLLoader and URLRequest to maintain a BOSH connection, so I welcome solutions applicable to this specific case. However, if there are NetConnection-specific solutions, I'm sure I can learn from them too.
I'm happy to accept that this callback won't be run on a kill -9 but it would be nice to have the more graceful exit paths allow for some code execution.
It seems like the better solution would be to do this via the server side no? The server should be able to detect the disconnection, where you could then invalidate the session.
However, you could go with a client/socket based solution, albeit much more overhead. Using FMS or some other rtm real time server you could dispatch events to your web server that a connection has dropped, (though you might have issues in the case of low network connectivity, or an internet drop). I would suggest going against this though, as in my experience, FMS sucks :)
Is setting extremely low timeouts not a possibility? (i.e. < 10 seconds)