문제

I have got the solutions which is using xvfb to specified a display to selenium, when I test my web program. Envviroments: CentOS6, Selenium2, robotframwork, Firefox. And My steps are:

   startup vncserver specified displaynumber. vncserver :6
   set DISPLAY with same number. DISPLAY=:6
   test my project.
   kill vncserver. vncserver -kill :6

And firefox can startup correctly. Now, I know what to do to startup firefox, but I dont know why. What's the relationship among selenium2, vncserver, xvfb, robotframework? For short, I want to know how selenium2 or robotframework use xserver from vncserver or xvfb. I did not find my answer in http://docs.seleniumhq.org/docs/ and https://github.com/rtomac/robotframework-selenium2library. Anyone knows that? Any references? thx

도움이 되었습니까?

해결책

I am not an expert but I will try to give an explanation of how I understand it.

By default, your Centos has no display configured.
It means you can not launch any application that has graphical interface.
So you not launch Firefox.

xvfb and vncserver allow you to set-up such a display. xvfb will create a in-memory display.

Then, "set DISPLAY" will tell your OS which display to use. If you set it to the xvfb you launched, then you are able to launch graphical app on your centos but they will not show up as they are in memory.

Then, for the Robot/Selenium part, they are not aware of all that.
Your Robot Framework test will call Selenium library that will launch Firefox as you would launch it from the command line, so it will be launched on the xvfb display.

So to your question "how did selenium know that variable DISPLAY has already been set?": selenium does not need to know. He sends it to the current DISPLAY and it will be the one you configured.

Hope this helps you to understand.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top