Centos6.5 install the virtual image environment Xvfb and chrome

Source: Internet
Author: User

Centos6.5 install the virtual image environment Xvfb and chrome

Xvfb is a display server that implements the X11 display service protocol. Unlike other display servers, Xvfb performs all graphic operations in the memory,

No display device is required.

The current test machine does not have a graphical interface. We can install Xvfb and then perform a test dependent on the graphic interface, such as webdriver case.

  1. Yum install-y Xvfb
  2. Start Xvfb
    Xvfb-ac: 7-screen 0 1280x1024x8
  3. Start firefox or chrome
    Export DISPLAY =: 7 (same as the number in the previous step)

Firefoxwww.baidu.com

Ignore the following error: Xlib: extension "randroid" missing on display ": 7 ".

DISPLAY is used to set where the graph is displayed, as shown in the preceding example, to connect to the local machine in unix socket mode (/tmp/. X11-unix/X7 ). The format of the DISPLAY environment variable is host: NumA. NumB. host indicates the host name or IP address of the Xserver. The image is displayed on this host,
It can be a Linux/Unix machine that starts the graphic interface, or a Windows machine that runs on Windows platforms such as Exceed and XManager.
If the Host is null, The Xserver runs on the local machine, and the graphics program (Xclient) connects to the Xserver using unix socket instead of TCP.
When a TCP connection is used, NumA is the connected port minus the value of 6000. If NumA is 0, it indicates that it is connected to Port 6000;
When using unix socket connection, it indicates the path of the connected unix socket. If it is 0, it indicates that the connection to/tmp/. X11-unix/X0. NumB is almost always 0.

Before running the webdriver case in Python, you must first install the python environment and the module required for testing.

4. Download pip's Installation File get-pip.py:/home/bi_test

5. root run: python get-pip.py

6. install the dependent module required for the test: pip install "module name"

7. Run the following simple test case:

# Coding = UTF-8

From selenium import webdriver

Browser = webdriver. Firefox ()

Browser. get ("http://www.baidu.com ")

Browser. save_screenshot ("capture.png ");

Browser. quit ()

You can see the file capture.png in the current directory.

8. Install chrome in centos6.5

Chrome itself does not support centos6.5. Although there are some rpm on the Internet, it is not easy to use after installation. There are many pitfalls. It is recommended that you upgrade a testing machine to centos7 directly from Xiaoqiang.

(Centos7 supports chrome and Docker by default, with many benefits ). Here is a simple record of how to install chrome in centos6.5:

  • Yum install-y lsb
  • Yum install-y xdg-utils
  • Yum install GConf2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.