How to make your selenium script unbreakable? - selenium

I am writing a selenium script using Java to automate a website workflow. I want to run this script 24/7 and make sure that it's always running without any crashes. I want to make it unbreakable.
Now let's say that the script has been running fine for some hours and suddenly chrome crashes so how do I make my script launch the chrome and start the execution from the start? Do I need to use any framework? I am learning TestNG.

Related

How does the elixir community recommend setting up integration tests with chromedriver?

I am using Hound (https://github.com/HashNuke/hound) for integration testing a Phoenix application. I have chrome and chrome headless working. To get it working I have another terminal window running chromedriver (installed via brew). This feels odd to me. Is there a library or test setup that would feel more "integrated" into the application? What's the Elixir way of doing this?
In the Ruby world there's the webdrivers gem (https://github.com/titusfortner/webdrivers). As far as I know it downloads a specified driver (lets say chromedriver) to $HOME. Then with every test run, the test uses the driver downloaded to that destination to execute the tests.
Before the webdrivers gem there was chromedriver-helper gem. Before that it was phantomjs. These implementations made it so running integration tests required 1: downloading the driver 2: running the test
In Elixir (with Hound) I have my tests working by first running chromedriver --verbose in a terminal split, and in the other screen I run mix test. This works fine but feels disjointed. This adds extra steps, 1: download the driver 2: start the driver 3: run the test 4: stop driver
I could write a script manually to run chromedriver in the background, and stop it after the tests are run.
I am new to the Elixir community and so I've researched a lot. It's still not clear to me if there is a "traveled path" I should go down vs just hooking everything up manually.
Have I missed a recommended abstraction? Is this intentional? Is this "just not created, yet"?
Thank you
Have you checked out wallaby? See https://github.com/keathley/wallaby

Running webdriver IEDriver on Jenkins fails

I have a small C# webdriver test suite dll which I recently created...
Runs fine in Visual Studio
Runs from the command line perfectly using the NUnit 3 console runner.
I have Jenkins installed on my laptop (for testing before I put it into my live Jenkins), running with my Windows credentials. When I execute the test suite using the same NUnit3 console runner command I used before, all the tests fail, can't even log in as it can't find any elements. I took screenshots with Selenium & it's just a black rectangle!
Anyone have any ideas on how to get IE behaving - I bet it's a Windows permissions thing from Jenkins. Thanks!
I'll answer my own question.
Turns out you can't do what I'm attempting - it's a known issue with the way IE is built. What I had to do is install a new Jenkins node on another machine and get that to run the IE tests. That way it did work.

When selenium test runs by Jenkins and MSUnit, the browser doesn't come up however there are valid results

I put together a machine (Windows Server 2012R2) for POC reasons where a Jenkins installed and it executes Selenium UI tests using msunit
But, when I log in the server where the Jenkins runs and I watch what happens during CI build (compile and test execution) I can't see that the browser (Firefox) starts automatically, however, the test results and the logs show that a browser was executed.
My question is that, what the is happening when my tests are executed by Jenkins? If I execute the command which from visual studio on the same machine then I can see that Firefox starts, does what is programmed in the tests and the results are in the result.trx.Can I somehow set up Jenkins the way the browser really executed (I can believe it when I see it :)
In Jenkins when you run selenium test cases, they are executed in the background by default.
Your Jenkins might be configured to run those test cases in some video buffer(usually it happens on Linux but can also be configured on Windows) or in a headless state.
As your question, if you are using MSTest which basically used to convert the test cases result from trx to JMX format but also can be used to run selenium tests. when you run the same in Jenkins it will run in background on any slave or on master.

What could be causing selenium tests to run differently on a different machine?

I'm using selenium and phantomjs to run automated tests. My tests run fine on my local machine. I need to run my tests on a windows server as part of a scheduled task that then emails the results each morning. When my tests are run on the server, a good majority fail and the screenshot that is taken upon failure is blank. Logs show it would appear its failing to load some pages when navigating from one page to another.

selenium script has to run continuously in server with out using eclipse

is it possible to run selenium script in server without using eclipse or command prompt.for every fixed time intervals my selenium script has to run automatically in backend with out any browser opening
This can be split into two questions;
Can I schedule a Selenium test?
Yes, there are many options including using a CI tool such as Jenkins, Hudson, Team City,etc. Alternatively you could write a shell script to run the command line, and schedule this to run every x hours.
Can I run Selenium without opening a browser?
Yes. As mentioned before you could go headless, but depending on complexity of your application and test, you may find headless is not suitable. However, you can use RemoteWebdriver to launch a browser on a different machine but the test would still be run on your back end, it would just be the browse launched remotely. See https://code.google.com/p/selenium/wiki/Grid2 and https://code.google.com/p/selenium/wiki/RemoteWebDriverServer