Selenide - How to run it with a headless Chrome? - java

We are trying to developer an automation test, and we found Selenide an interesting and easy framework for running the UI tests.
Selenide needs as an input the browser to use.
So we are passing 2 arguments to the program:
selenide.browser=Chrome
webdriver.chrome.driver=C:\\chromedriver_win32\\chromedriver.exe
And the code looks something like that:
System.setProperty("webdriver.chrome.driver",inputParams.get("webdriver.chrome.driver"));
System.setProperty("selenide.browser", inputParams.get("selenide.browser"));
open("http://v3is245.prod.leadspace.com:20400/ui/jobs");
All works fine, but we also need it to run in headless mode.
We tried several ways to run it in headless mode, (different param in the selenide.browser, PhantomJs and some other combinations, but with not success till now.

It turned out that in order to run Selenide in headless mode we need to add system property selenide.headless=true

You could do also:
Configuration.headless = true;

Related

Automation Testing without opening browser or any UI

I have been doing automation testing and it is working fine. It is working like open a browser, interact with elements and execute test cases based on given conditions.
I am using Selenium Webdriver, TestNG, Java and Maven for this.
Now from seniorI got request that we perform same test cases without open browser or interact with UI. How it is possible in selenium webdriver?
They said they will provide me API, It is possible to do same using API. If yes then kindly provide a small example so that I can know more about it and will implement then.
I have tried PhantomJS, HtmlUnitDriver but all have their disadvantage. I think Xvfv is the better solution, no need to change code just run your script heedlessly.
Install Xvfb
sudo apt-get install xvfb
And use this command to run mvn script heedlessly
xvfb-run --server-args="-screen 0, 1624x1068x24" mvn test
I hope it will help you.

Is there any automation code that always works perfectly without exceptions

I am new to test automation (Selenium WebDriver) and I have created a good automation code, that sometimes runs perfectly, but most of times it just fails, without any good reason, with no code changes.
Is this normal or the problem is my code?
I just want to know if anybody faced that problem before or it's just me.
Tests that rely on external systems are often a better fit as integration tests, and Selenium tests definitely belong in that category. If you are using Maven, you can run the Selenium tests using the Failsafe plugin instead of Surefire. This allows them to "fail" without breaking the build, but you can still have ordinary unit tests that must succeed.
With reference to https://sqa.stackexchange.com/questions/9007/how-to-handle-time-out-receiving-message-from-the-renderer-in-chrome-driver , following are recommendations :
Solution 1: There are some plugins like flash player which may hangs the browser inconsistently waiting for some resource during test run, try disabling such plugins while starting the test using the chrome switches. http://peter.sh/experiments/chromium-command-line-switches/
Solution 2: The browser might hang waiting for some third party ads. Try disabling ads using some ad blocker extension or block the url pattern using the custom proxy configuration.
For inconsistent browser hangs, Try to find which process hangs the browser. 1.Unlike firefox chrome creates separate process for browser, tab, extension and plugins. 2.When the browser hangs check is there any new process(shift+Esc) like Web Worker:blob appended with an third party url, then follow #2 3.or else if there are more separate process opened for plugins try #1
Please refer to below link :
https://sqa.stackexchange.com/questions/9007/how-to-handle-time-out-receiving-message-from-the-renderer-in-chrome-driver

How to run Selenium tests with single click or single command?

I'm writing Selenium tests using Java + Maven + Selenium WebDriver. Our customer wants these tests in such a way that they can run tests easily without much technical stuff needed.
I've all my tests under src\test\java folder. Is there any way where I can give jar file or so to the customer and they can run tests by simply clicking on it or by hitting some command on the command line.
Please point me to documentation or video using which I can achieve this.
I've been using Visual Studio to write my Selenium tests in C#. I am able to build my project to a console application in Visual Studio that contains the required files like the Chrome webdriver. It can be run from this single application file with one click. The console then prints out if the test is a success or if their are any exceptions. You should also be able to integrate a headless browser like selenium has on their site. This would allow the test to be run with one click and no browser will pop up while the tests are running.This is all the experience I have and it has worked well for me. Hope that this information can help a little.

How to run a test case without opening the browser window?

I have created a set of test cases using Firefox Driver in Eclipse IDE.
But now I need these test cases to run without opening the browser window. How can I achieve that?
Presently I am using Firefox Driver Web Driver that runs in Firefox Browser.
Can some one help me with an example?
If you do not need to think about compatibility of different web browser, you could try Celerity. It could be run automated test script without any browser window.
http://celerity.rubyforge.org/
It is based on JRuby, and is very easy to learn and use.

Stuck to run Selenium RC script simultaneously in multiple browsers

I am working in selenium RC with Java+Junit+Eclipse.
For my project I have developed script which will run in only one browser i.e Firefox through the below code..
public void setUp() throws Exception
{
selenium = new DefaultSelenium("localhost", 4444,"*firefox","http://www.google.com");
FinalTestSuite.selenium.start();
selenium.windowFocus();
selenium.windowMaximize();
}
Now I am stuck because requirement came to run the script simultaneously in multiple browsers.
I didn't find any helpful article..
Please anyone working on this same scenario...HELP! :)
You can use Selenium Grid to run a script in multiple browsers. Also you can refer this blog regarding its setup configuration.
Hope this helps.
Create a runner which will run the suite containing setUp()
Pass the browser name by variable to setup.
You can run the code multiple times with multiple RC server started on different ports.
e.g. My projects runs through ant so i pass -Dargument=*firefox on command prompt then my test cases run on firefox browser also you can pass the port number and host ip.
Thanks
The best thing to use for parallel execution is TestNG. But since you are using Junit , the following link may help you in that.
http://blog.varunin.com/2011/07/running-selenium-tests-on-different.html

Categories