How to launch Selenium htmlSuite on a distant RC server? - java

We have a huge amount of htmlsuite deisgned by business analyst and we want to launch them during continuous integration (or every night) automatically. The problem is that the machine with selenium-RC is not the same one than the continuous integration :
In java, we used the client-driver and it works fine :
selenium = new DefaultSelenium(serverAddress, SERVER_PORT, browser, url);
selenium.start();
and then selenium.click(..) etc ..
If I use a seleniumServer that I created and launched in java, I can launch HTMLSuite, it works fine too :
RemoteControlConfiguration rcc = new RemoteControlConfiguration();
rcc.setPort(SelHelper.SERVER_PORT);
seleniumServer = new SeleniumServer(rcc);
seleniumServer.start();
HTMLLauncher launcher = new HTMLLauncher(seleniumServer);
If I launch a selenium server independantly (e.g. distant server) and I try to use the htmlLauncher, I does not because it takes as an argument a SeleniumServer that I can not access...
Anyone has a solution ?
The plan B would be to launch in SSH from continuous integration a .cmd file on selenium RC machine containing something like :
java -jar "X:\01_Robot\SELENIUM_RC\selenium-server-1.0.1\selenium-server.jar" -htmlSuite "*firefox" "http://www.myapplication.com" "X:\mytestsuite.html"
But it would be ugly and I want to do that only if I don't have any choice.

I finally found a "HtmlClientDriver" (similar to javaClientDriver) on : https://github.com/takamori/selenium-html-client-driver/wiki which parse html selenese and launch commands on a rc server.

I have implemented an example of a remote webdriver grid configuration in this project on Github here. You might be able to glean some good info from it. See the two .bat scripts "startWebDriverGridHub.bat" and "startWebDriverGridNode.bat". Run the former on your local machine where you are developing (or on your Jenkins server) and run the latter on the remote machine.
I wouldn't recommend starting the grid the way that you have done it, although it is doable, I would say its beyond the scope of a simple Stack question.
Also, don't use HtmlClientDriver. If you want headless, look at PhantomJS driver. If your real intention is to drive a browser on the remote computers desktop, I would use "RemoteWebDriver" in the form of Firefox driver, Chrome, or IE driver, via the scripts I provided above.

Related

Arquillian Drone + Selenium Grid 2.0: Keep unused Browser alive

I am using Arquillian Drone + Graphene (standalone) for driving automated Browser Tests on a Selenium Grid 2.0 hosted on another machine. The tests are run via Arquillian in client mode (the server to be tested is already running)
Some of my tests require using two browsers at once, therefore i added a second Browser according to the Graphene Documentation.
So far everything is working.
The Problem:
Running a test which has both browsers injected has both of them started up before any test of the class is run. As there may be a few tests before the second browser is used, it most likely has already timed out.
Of course i could set the Selenium Grid Settings to never (or very late) close the browser via timeout, but that cannot be the solution.
Is there a way to check if the WebDriver is still up and restart it via Drone?
Without Drone i simply could check if the driver quit (e.g. like this) and create a new instance. But i want to have it injected via Drone.
In the best case i would like to be able to define when Drone should open the browser or even better keep it open until the test is finished.
If thats not possible a way to restart it would be sufficient.
I solved the Problem by directly injecting the WebDriver into the test method.
public void test(#Drone #Browser2 WebDriver webdriver){...}
I am still not completely happy with this solution but it does work.

putty automation using selenium webdriver

I have given a scenario of automating winscp, putty and database verification.
winscp - Need to move files from local to server - So planning to do this via AutoIT tool.
Putty - Need to run commands in linux to batch run the moved files - Please provide information on how to automate this part through selenium with Java?
Database - need to wait for 10 minutes after running the commands in putty to verify in tables.
Selenium WebDriver is used for browser automation testing (hence the name WebDriver), so calling PuTTY, database, WinSCP are slightly out of scope for it.
However, this doesn't mean your automated 'Selenium' tests just need to run Selenium, as it's all Java you can use whatever libraries you see fit in your test. So as part of your test, you can use libraries (e.g. AntBuilder to both run SSH and SCP and JDBCTemplate to query databases) to run these parts of the test!

Use new temp firefox profile each time with selenium server

Im using the selenium server 2.35.0 which im starting using
java -jar selenium-server-standalone-2.35.0
And then running my tests from a php script using the Testing_Selenium binding.
It seems to be opening in the same Firefox profile each time, how can i change this ? I understand this is not the default, but it has been changed somewhere down the line and im not sure how to undo it.

How to launch client machine exe file and not dependent on browser?

I want to launch a exe file when click on the button from my appliction and that should be from client machine. I tried with following solutions.
Runtime.getRuntime().exec(".....\\somefile.exe");
when I follows the above solution then it was opened server machine exe file.
I applied one more solution in script code
i.e
**var ws = new ActiveXObject("WScript.Shell");
ws.Exec("...\\somefile.exe");**
the above code working fine but I need to enable ActiveX related script enble mode in client browser window manually and it is only applied for IE only.
Let me know any solution that is browser independent and without activex enable option.

For Selenium, do I need to start the java server?

$pip install selenium
$sudo apt-get install firefox xvfb
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get("http://www.yahoo.com")
This is what I have so far, for Selenium. It seems to work, except it says, "Error: no display specified"
My question is: Do I need to run the selenium jar? It doesn't seem to matter whether I run it or not...
First let me define for you client mode and server mode:
Client mode: where the language
bindings connect to the remote
instance. This is the way that the
FirefoxDriver and the RemoteWebDriver
client normally work.
Server mode:
where the language bindings are
responsible for setting up the
server, which the driver running in
the browser can connect to. The
ChromeDriver works in this way
In the current trunk all of the browsers can run in client mode although you must specify the ChromeDriver.exe path. Server mode can be used to do the same thing. You can set up the jar to run to act as a server for a particular browser. You then connect to that server. If you do this you'll see a Jetty server being set up and it handling requests. If this is not happening then you are not using server mode. As I can see from your code you are currently using client mode so there is no need to run the jar unless you want the extra remote functionality of it.
Running the jar is useful if you want to run tests on a remote machine in which case you run the jar there then connect to it from your local machine. The jar will then deal with launching browsers on the machine it is running on and forwarding actions to it.
I believe in the past with the Selenium RC API, it was necessary to always run the jar but with WebDriver this is not the case.
No, you don't need to run Selenium RC server. You can also use the Webdriver method instead, the preferred method for functional testing, which is a "direct" control of the browser as far as I can tell.
I think the server method "Selenium RC server" is more useful for load testing or multiple user testing, especially in the context of using it with Selenium Grid .

Categories