Selenium virtual display on a remote server

Source: Internet
Author: User

Selenium after installation, there is always an error when calling in Python

Here the browser Flash is mainly because the server side does not show the relevant driver, installed a virtual display after the problem solved

1sudoApt-getInstallXvfb
2 sudoPipInstallPyvirtualdisplay

The method used will need to import the virtual display module, turn on the display before launching the browser, close the display after the end

1 #!/usr/bin/env python
2#Coding:utf-8
3
4 fromPyvirtualdisplayImportDisplay
5 fromSeleniumImportWebdriver
6
7display = display (visible=0, size= (1024, 768))
8Display.start ()
9
TenBrowser = Webdriver. Firefox ()
OneBrowser.get ('http://www.baidu.com/')
APrintBrowser.page_source
-
-Browser.close ()
theDisplay.stop ()

Selenium virtual display on a remote server

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.