Automation UI testing with VNC

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 EXIT
setup_vnc
#doing some process

Reference

  1. Virtual Network Computing
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值