Is it possible to close remote web driver connection and initiate a new one for long running tests in Selenium Serenity - serenity-bdd

We have a remote test execution framework working fine against a cloud vendor for real browser/mobile device testing. When tests grown complicated with several steps and a lot of examples/test data under a scenario, the connection is lost between the remote site and local client resulting in test failures/errors.
Looks like when the framework is ran, it initiates driver and opens a single http connection (long lived) and a new session is initiated for every test scenario in the same connection. Also framework is doing a lot of SYNC calls in background for keeping that connection alive.
We have tried headless mode, disabling screen/video at the cloud providers end, but still fails if there is any interruption in public cloud connection.
The core reason would be unstable internet connectivity to hold for long running test cases. We don't have the budget to explore private cloud offerings. The only solution would be somehow instruct serenity to close and initiate a new connection for long running tests.
Does anyone has any idea if this can be achieved in Serenity? Any one already explored the same?

Related

Selenium c# MSTest Specflow execute tests to another device

in my job we have a .NET custom application for testing, we are sending API Requests to another PC where the IIS Express web server is up and running with 81 port. after that test execution starts.
Now I've implemented the MSTest+Specflow project with selenium c# / VS19. on my local machine, it works perfectly, executing/extending reports.
I'm interested in which way can be achieved to send API Request or something to another PC that will starts executing tests. (I have access to that computer with RDP), I don't wanna connect via RDP every time I want to execute tests. for example, sending API Requests via postman to that IP address which will start execution automatically will be perfect.

Robot Framework executing test on RDP client

I have my robotframework setup on my PC.
I would like to connect to a remote windows client, have it open a browser and access a URL.
Verify that the pages has loaded.
Pretty basic but since I am new to RF, I wanted to know how that would work.
For Linux machines, I would use the SSHLibrary and just execute commands (wget) but for the windows machine, I need to use the browsers.
Do I need RF installed on the destination client RDP?
Do I need the webdrivers for each browser on the client RDP?
How would I go about logging in the Windows machine through RDP?
After Logging in with RDP, I run the same "open broswer" with broswer and URL?
Thanks!!!
The use case you describe - a browser to be opened & controlled on a remote machine, is precisely what Selenium solves.
Though in day-to-day work or debugging we are usually starting a local browser, SE is preliminary designed for remote execution. So head to www.selenium.dev, and focus on the Grid - that's the component you are after.
I'm that approach, answers to your specific questions:
no, you need Robot Framework and selenium library on the local machine, and only selenium & webdriver on the remote.
you don't need the drivers on the client - the selenium library is all you communicate with in your code; you need them installed in the remote only.
on the local you will get the logs of the webdriver commands execution; actual browser manipulation logs are only on the remote and the hub (but these are really debugging ones, everything high-level for the functional execution is local).
you don't really log into RDP with this approach (RDP is totally out of the picture here), and yes - your code is the same as running on local browser - Open Browser, Get Text, etc - but, executed on a remote machine.
If you want to see why 1) and 2), head to the answer over here (shameless plug 🙂)

How does selenium behave without an "active session"

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.

Any idea for executing Selenium webdriver + Java/Python tests from Cloud

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.

Selenium Chromedriver on remote Mac machine very slow and timing out

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