Dealing with timeouts in Sauce Labs - selenium

I have Web Driver code that works without issue when running on a local instance of a browser. My code interacts with the browser, but has a period where it kicks off some background tasks via terminal in order to set up data for the remainder of the test. This is an end to end test and it needs to execute in this order, leaving the browser idle for a short period of time, usually under 5 minutes. After the background tasks complete, the browser is then again interacted with.
Unfortunately when I run my rests remotely from Sauce Labs, when running the background tasks Sauce Labs finds the browser as being inactive for longer than 90 seconds and assumes there is an issue. This results in a failure even though the test never fails. I can't seem to find anything in the documentation regarding how to increase the idle timeout. Is there a way to do this?

Saucelabs has a few different types of timeouts:
Max test duration
Command timeout
Idle test timeout
More info: https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options#TestConfigurationOptions-Timeouts
Either the max duration or idle timeout should help you out. I think the idle time still burns down sauce test minutes though.

when you set up your desired_capabilities add:
desired_capabilities["idle-timeout"] = "180"
I did 180 seconds here, but you can do whatever...

Related

How to Advance time by atleast 45 minutes in Kotlin Espresso Test

I have a scenario, wherein if the user stays idle on the screen for 45 minutes, I will have to transfer the user to home screen.
In my Espresso test, I want to recreate the scenario, and i would not want to wait for 30 minutes for that to happen.
Is there a way we can advance time in Espresso?
I have checked idlingresource and waitingforview etc, but none of them seemed right to me. Can anyone guide me on how to advance time in espresso?
I don't know about manipulating the system clock for a test, but instead of hardcoding a 45-minute wait, you might want to handle the time limit with dependency injection - either by setting a timeout property, or passing in a Clock object that the code refers to, instead of accessing the system clock directly.
That way your test can either configure it with a more useful timeout setting, or the Activity (or whatever) can poll a Clock that you're able to manipulate from the test. (Having a configurable timeout would allow you to do things like set it as a user option too, maybe change the value in power-saving mode, etc)

How to design a stress test for e-commerce application with jmeter

I am conducting a stress testing for a web application but I am quite confused how should I design the test cycle. So I have a test script with few controllers for example homepage, login, product catalogue and a uniform random timer. But How long and how many time should I run the the stress test to make a proper decision. Also for example I am using ultimate thread group for testing and how many user should add each time and how long the ramp up, hold time and shutting time can be for a proper result? Thanks in advance!
Stress test is about finding the boundaries of your application, the simplified approach is:
Design your test to simulate real user(s) activities with 100% accuracy, JMeter should produce the same requests as the real browser, you can cross check the requests sent by JMeter with "Network" tab of your browser developer tools
Start with 1 virtual user
Gradually increase the load
Look into correlation of increasing load (i.e. Active Threads Over Time listener or equivalent) with the other performance metrics, the main ones are response time (i.e. Response Times Over Time or equivalent) and number of hits per second (i.e. Transactions Per Second or equivalent)
On well behaved system when you increase the number of users the number of hits per second should increase proportionally, response time should remain the same, no errors should occur.
However if your system under test has limited hardware/scaling capabilities at certain point of time you will face the situation when the number of virtual users will be growing and the number of hits per second will remain the same or go down or errors will start occurring. This means that you found the bottleneck

Jmeter: How can I keep 1000 or “X” users login requests session alive using JMeter?

Here is my Test Scenario:
First, I am generating a load which includes only Login Requests (say for 1000 users). I am using "Ultimate Thread Group" and "Constant Throughput Timer" in my script. Constant Throughput Timer Value=120/sec is used. I want to run this test for five or ten minutes. My load would be held for 3 minutes.
During this Test(while loads are held) , I am sending another set of login requests from the different machine (say for 100 users). I want to measure the response time of this 100 users login which I've generated from the different machine.
But My Requirement is: While I'm sending 100 users login requests, My Previous 1000 users login requests session should be alive on the server. I've also checked "Use KeepAlive" in my login sampler.
So, How can I achieve this?? How can I be sure that my previous all the login requests sessions are held on the server?
Test Script:
Image 1: Screenshot for Ultimate Thread Group
Image 2: Screenshot for Constant throughput timer
You need to consider following fields of ultimate thread group -
Shutdown time for 1000 threads ( ramp down time)
Hold load for - for 1000 threads.
Initial delay for 100 threads. ( time between starting the script and first server hit)
start time for 100 threads - make sure the 100 threads get ramp up before 1000 threads get shut down. Each thread would be start after ( start time/ start thread count ) seconds from the previous thread.
you need to configure these values in such a way that the first 1000 threads don't get shut down till the all of the next 100 users are active.
Also you can use the active thread over time graph which is provided with in the ultimate thread group to see how the many threads would be active.
P.S Don't confuse the thread number with number of requests, each thread will create multiple requests for seconds in field " Hold Load for ".

Selenium FluentWait wait before starting to poll

I'm using Selenium WebDriver to get some content from a site that dynamically loads it using Ajax. I created a custom Wait class to check for a condition on the page to make sure that the page has loaded before continuing. I used FluentWait to set the polling interval to 2 and timeout to 10. However, I noticed that it checks for the first time at time increment 0, then waits 2 seconds if the condition was false, then checks again, etc.
Since the page takes some time to load, it always is false at the first check, but usually is true at the second. Is there any way to make Wait wait the 2 seconds before checking for the first time? I.e. check at times 2,4,and 6, if necessary, rather than at 0,2,4,and 6?
Thanks,
bsg
EDIT
I've been asked to mention why I want this behavior - after all, I'm using the Wait the way it's meant to be used. The benefit I get from it returning true the first time is the following: WebDriver apparently opens a new socket every time it issues a command to the browser. For whatever reason, these sockets don't always get closed after the call executes. When executing a large number of calls in a short time (for instance, when repeatedly checking for a condition, which is what Wait does), it is possible to run out of virtual sockets, and the driver crashes. (The lack of enough virtual sockets seems to be a known issue on Windows 7, but I can't modify my system.)
The fewer calls to the driver I issue in a short period of time, the less likely it is to overrun the number of available sockets. I have observed that the first check never returns true, and therefore it's just opening a socket for no reason, making the program more likely to crash. That's why I want to wait. I hope this explanation is helpful for someone searching for information as to why they keep getting SocketExceptions in WebDriver.
The obvious answer would be to just insert a time.sleep(2) (or similar method) before your first check. Would that work for what you're trying to do?

Long polling Windows Phone, 60 seconds TimeOut

HelloA Windows Phone application need to connect to a server and get messages from it. This is done using WCF and long polling on the server. 3 minutes is the timeout defined on the server. Call from windows phone is done using HttpWebRequest.
The problem is that Windows Phone devices have a timeout of 60 seconds for get request (emulator have a different value, greater than 3 minutes).
Currently i can't decrease server timeout. Doing a new GetRequest after the 60 seconds doesn't get anymore messages.
Does anyone have an idea ?
Thanks
I don't think leaving a connection open is a good idea on mobile devices. I'm assuming that's what you're doing. In my app, I would just poll whenever needed by creating a new HttpWebRequest. But it made sense to do this in my app, because I would be updating train arrival status every 40 seconds.
If you're trying to pull data on a given schedule, put a timer in and just call the webserver every 3 minutes or whatever the requirement is.
If you want to be able to check things (when the app is closed) or if there's rarely fresh data on the server, then you'd need to implement a Push mechanism.
Update: Here's a good article on dealing with the timeout issue - http://blog.xyzzer.me/2011/03/10/real-time-client-server-communication-on-windows-phone-with-long-polling/
Update 2: What if you arranged it so that, you have cascading connections - what I mean is since you can't go beyond 60 seconds per connection, you can write a class that'll house two connections and once one of them is about to timeout, say several seconds before, you can start opening the other connection - you can pick the timing so that there's at most 5 seconds of overlap between them. This way you could have your always open connection.
Also see what these guys have done with the GChat app, they have their source code available at this link. This may provide a more proper design.