Running Test NG Selenium Tests Through SSH

2020-04-28 06:29发布

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?

3条回答
【Aperson】
2楼-- · 2020-04-28 07:10

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.

查看更多
男人必须洒脱
3楼-- · 2020-04-28 07:18

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.

查看更多
萌系小妹纸
4楼-- · 2020-04-28 07:25

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.

查看更多
登录 后发表回答