Selenium and Headless Environment

后端 未结 2 1760
时光取名叫无心
时光取名叫无心 2020-12-13 11:09

I recently installed Python 2.7, Robot Framework and the Selenium Library (I still don\'t know if I succeeded though...) on a Red Hat Server to run some test on a web applic

相关标签:
2条回答
  • 2020-12-13 11:37

    Using the X Virtual Frame Buffer (Xvfb):

    We can use xvfb to create a headless environment for selenium (for example, to run over SSH).


    Instructions:

    1. Start xvfb with the following options:

      $ Xvfb :89 -ac -noreset

      (where :89 is the virtual "display" created).

    2. Then, set the DISPLAY variable to be this virtual display:

      $ export DISPLAY=:89

    3. At this point, we can run the selenium server as desired. Examples follow.

    Run the server Java archive:

    $ java -jar selenium-server.jar

    In Python:

    from selenium import webdriver
    
    driver = webdriver.Firefox()
    ...
    
    0 讨论(0)
  • 2020-12-13 11:52

    Here is a simple Robot library just for that purpose.

    0 讨论(0)
提交回复
热议问题