I'm trying to use an EC2 instance to run several Selenium chromedrivers in parallel. When I run just one, it works fine. But as soon as I start a second Selenium process, both processes fail (as in, page loads hit max timeouts after a couple minutes).
I'm using a t3.large instance, which has 8gb RAM and 5Gbps of network bandwidth. It's not a cheap instance and costs $2 per day. I'm surprised that with these specs, it can't handle two concurrent Selenium processes because my personal laptop has no problem handling 4+ Selenium processes.
Additional info: I'm using pyvirtualdisplay on the EC2 box.
Wondering if I'm missing something here that is causing the poor performance.
Related
I try to run 10 user accessing a website concurrency by using Selenium Webdriver in JUnit and it caused my PC to lag because it open 10 Browser at the same time. I even tried to run Jmeter in Command Prompt, it is just laggy. Is there any methods to actually run 1000 user concurrently without stressing my PC?
Each browser has its system requirements, for example for Firefox 71 they are:
512MB of RAM / 2GB of RAM for the 64-bit version
Pentium 4 or newer processor that supports SSE2
If you want to kick off several browsers - you need to have:
2 GB of RAM per browser instance
1 CPU core per browser instance
For 10 browsers you will need to have 11+ CPU cores and 22+ GB of RAM, for 1000 browsers - proportionally more.
If you have to conduct performance testing using real browsers you will need to go for Distributed Testing and allocate sufficient amount of machines to act as load generators. Remember that machines must not be overloaded as if they will not be able to operate fast enough - you won't get accurate results.
Another option is migrating your Selenium tests to JMeter, you can basically run your Selenium tests through JMeter proxy so JMeter will be able to capture the relevant HTTP requests and convert them into HTTP Request samplers or replay them via Proxy2JMX Converter module of Taurus tool, check out How to Convert Selenium Scripts into the JMX article for more details.
JMeter's HTTP Request samplers have very small footprint comparing to real browsers so you will be able to mimic several thousands of virtual users from a modern mid-range laptop given you follow JMeter Best Practices
I am running some time dependent tests in selenium. For some reason when a insatiate a chrome driver, the load time of the browser window is varying. How can I fix this to get the load times consistent and stop the chrome browser windows from loading so slow?
It has nothing in common with Selenium, you need to get a snapshot of what's going on with your operating system when you launch the browser, for example using Windows Performance Monitor
Blind shot: Chrome browser is very memory intensive (you can check how much RAM it consumes using Windows Task Manager and if your machine is short on RAM it starts intensively using page file to store some memory pages to disk and since disk is much slower comparing to the RAM - you're getting inconsistent results.
The only way of effective speeding up Selenium tests is Parallel Execution via Selenium Grid or by means of your underlying unit testing framework.
I've been working with Selenium for a few years already.
I started with some little stuff in Java and in my previous job I did a project using C# bindings with SpecFlow framework, page objects model, I dealt with complex locators, some JavascriptExecutor even some browsermobproxy work, bottom line I have some experience with Selenium.
Still there is something that is not clear to me.
Is Selenium expected to work properly when there is no "interactive session" into the machine that is running the code ?
Let's say that I connect into remote desktop to a machine in the cloud (Let's say Amazon or Azure), I develop a script and schedule a windows job to run it on the next 10 minutes, then I disconnect from the remote desktop session, the machine is on but no user is connected to it in remote desktop.
Will the script work ? Or depends what does it do ? Might some of the actions not work (Script might include changing the window size, sending keystrokes both through selenium sendkeys and by OS level actions) ? Can we ensure that any script that we developed and works OK while we are connected to the machine will also work when I'm not ?
I hope the question is clear, if not I can maybe explain further
Thanks !!!
Yes, Selenium can run on the cloud machine even though you are not connected to it. It should work without any issue.
As per my knowledge cloud machines are protected by firewall which blocks almost all the ports. You may need to get permission to use the default selenium ports like 4444 or 5555.
Also, may need to increase wait time because the cloud machines are slow in performance compared to normal physical desktop.
Usually cloud machines are linux based, you need to consider the environment as well.
I can't found any question/answer about that (probably I don't know how to find it...)
Could somebody give me a global idea to execute +200 Selenium webdriver tests (Python) from cloud servers/tools?
Thanks!!
rgzl
Another way is Saucelabs, using this service you'll be able to just send your Selenium
Java/Python tests
to their Cloud infrastructure for execution. The benefits of such testing are obvious – no need to waste time and resources setting up and maintaining your own VM farm, and additionally you can run your test suite in various browsers in parallel. Also no need to share any sensitive data, source code and databases.
As said in this acticle:
Of course inserting this roundtrip across the Internet is not without cost. The penalty of running Selenium tests this way is that they run quite slowly, typically about 3 times slower in my experience. This means that this is not something that individual developers are going to do from their workstations.
To ease the integration of this service into your projects, maybe you'll have to write a some kind of saucelabs-adapter, that will do the necessary SSH tunnel setup/teardown and Selenium configuration, automatically as part of a test.
And for a better visualization:
Here's a global idea:
Use Amazon Web Services.
Using AWS, you can have a setup like this:
1 Selenium Grid. IP: X.X.X.X
100 Selenium nodes connecting to X.X.X.X:4444/wd/register
Each Selenium node has a node config, running 2 maxSessions at once. (depending on size of course)
Have also, a Continuous integration server like Jenkins, run your Python tests Against X.X.X.X grid.
I am running a Selenium test suite on multiple browsers on a remote Apple Mini. I schedule these tests with Bamboo.
When running the tests on Chrome, they are extremely slow and some actions timeout, causing the tests to fail.
More interestingly, this only happens when Bamboo kicks off the test. When I kick off the tests from my local computer, they run fine.
I have read that Chromedriver performs poorly sometimes when automatically detecting proxy settings. I have addressed this but still the performance is poor.
Has something like this happened to others and does anyone know what could cause something like this?
Something similar happens to me.
The root cause can be in the network connection between the Bamboo server (where the project is built) and the Selenium server (which probably runs on another machine).
When you kick off tests suite from your local machine, you probably have the project build and Selenium running at the same place. So, the commands sent to Selenium do not have to pass the network stage and there are almost no delays.
Try to eliminate the slow connection or investigate if it is possible to build and launch your tests on the machine which runs the Selenium server.
I had this when running tests on Team City with multiple browsers on a remote Mac Mini.
After much head scratching we stumble upon the fact that tests sped up if we remotely connected or connected a monitor to the Mac Mini.
We can only assume that the Mac Mini is smart enough to reduce resource to GUI activities if it knows there is no mechanism to attach a GUI.
Therefore, we purchased a very cheap monitor and left it attached to the MAc Mini, and all started running normally