Ubuntu无桌面进行Web浏览器测试

前端之家收集整理的这篇文章主要介绍了Ubuntu无桌面进行Web浏览器测试前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

主要原理是利用xvfb提供的显卡帧缓冲区,让浏览器以为有桌面

Install xvfb in ubuntu:

sudo apt install xvfb

cat > /etc/init.d/xvfb <<"EOF"

XVFB=/usr/bin/Xvfb

XVFBARGS=":99 -screen 0 1024x768x24 -fbdir /var/run -ac"

PIDFILE=/var/run/xvfb.pid

case "$1" in

start)

echo -n "Starting virtual X frame buffer: Xvfb"

start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS

echo "."

;;

stop)

echo -n "Stopping virtual X frame buffer: Xvfb"

start-stop-daemon --stop --quiet --pidfile $PIDFILE

echo "."

;;

restart)

$0 stop

$0 start

;;

*)

echo "Usage: /etc/init.d/xvfb {start|stop|restart}"


exit 1

esac

exit 0

EOF


chmod +x /etc/init.d/xvfb

export DISPLAY=:99.0

/etc/init.d/xvfb start


1.2. Install chrome in ubuntu:

sudo apt-get install libxss1 libappindicator1 libindicator7

sudo apt-get install -f

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

sudo dpkg -i google-chrome*.deb

sudo ln -s /usr/bin/google-chrome /usr/bin/chrome



1.3. Install chromedriver in ubuntu:

wget http://chromedriver.storage.googleapis.com/2.25/chromedriver_linux64.zip

unzip chromedriver_linux64.zip

sudo mv chromedriver /usr/bin/



1.4. Install firefox in ubuntu:

sudo apt install firefox


1.5. Install geckodriver for firefox in ubuntu:

wget https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz

tar zxf geckodriver-v0.11.1-linux64.tar.gz

sudo mv geckodriver /usr/bin/

原文链接:https://www.f2er.com/ubuntu/351203.html

猜你在找的Ubuntu相关文章