Running Test NG Selenium Tests Through SSH
Asked Answered
C

3

1

I have a server, A, that has eclipse, testNG, selenium, and stuff set up on it. I have another server, B, with Bamboo setup on it.

I am able to, on server A, run a testNG script that runs a set of selenium tests on a web application that I'm developing. I used the java command that is in the properties of the vm that was shown in eclipse to create an ssh task on server B through Bamboo.

However, it seems like it just sits there and never actually finishes the job in Bamboo.

I tried to ssh to Server A from another laptop, and ran the same command. I don't get any error messages or anything, but the system seems to just freeze.

How do I fix this?

Combings answered 10/4, 2013 at 15:8 Comment(0)
S
2

Install Xvfb, which pretends to be a monitor, but doesn't show up anywhere.
sudo apt-get install xvfb.

If you want less errors add these fonts, but those warning aren't important.
sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

Then start it running and set your display to something the system won't use. Here is what I do, remeber the & makes the terminal run something in the background.
Xvfb :99 -ac &
export DISPLAY=:99
firefox &

Also I was having problems with a ruby on rails server disconnecting when I quit the ssh terminal. To fix that problem use Screen. Screen runs another terminal without being affected by the ssh.
sudo apt-get install screen

Then just start screen before you you do the stuff above.
screen


To get out of the current screen window just click "Ctrl + A" then 'D' and to get back in type screen -r.

Stedt answered 7/10, 2013 at 23:53 Comment(0)
R
0

Is the below an option for you?

Host A: have browsers and a selenium-rc always running and listening to whatever (4444) port; Host B: have TestNG + build job and have tests pointing to the selenium-rc of host A.

That is a regular setup for selenium and ci running on different hosts.

If server A runs a linux/unix, then just ssh-ing and launching browser (with selenium you'll end up with it trying to launch a browser) will not succeed.

Realist answered 16/4, 2013 at 22:4 Comment(0)
B
0

Try setting the DISPLAY environment variable to ":0" (or whatever the display is on your machine -- you can check by launching a terminal through the GUI and running "echo $DISPLAY"). I can launch firefox over ssh with the following command:

ssh somehost "env DISPLAY=:0 firefox"

But seriously, I second patrungel's suggestion -- use selenium grid / rc. It's designed for this kind of thing.

Belva answered 18/4, 2013 at 14:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.