Automation UI testing with VNC

来源:互联网 发布:网络造字 编辑:程序博客网 时间:2024/05/22 02:20

If we’d like to test with UI program that needs a display available, this is handy to run an VNC session during the testing.


Getting Started with VNC

1 Setup a vnc server

vncserver :1

If you haven’t run a VNC server before you will be prompted for a password, which you will need to use when connecting to this server. All your servers will use the same password, and you can change it at a later date using

vncpasswd

2 Teardown a vnc server

vncserver -kill :1

3 Create a function for reuse

setup_vnc(){    #FIX ERROR "vncserver: The HOME environment variable is not set."    [ -z "$HOME" ] && export HOME=/home/xxxtest    # default starting with :10    VNC_DISPLAY=10    # find a vnc display number hasn't been used.    while ! vncserver :$VNC_DISPLAY    do       ((VNC_DISPLAY++))    done    export VNC_DISPLAY    export DISPLAY=:$VNC_DISPLAY}teardown_vnc(){    vncserver -kill :$VNC_DISPLAY}

to enable the vnc session is released, there need to trap the exit signal

trap teardown_vnc INT TERM EXITsetup_vnc#doing some process

Reference

  1. Virtual Network Computing
0 0
原创粉丝点击