Selenium-Python Client Library - Automating in Background

后端 未结 2 744
一个人的身影
一个人的身影 2021-01-05 13:21

I am trying automate a login process to my web application using Selenium-Python Client Library. The ultimate goal is to learn Selenium\'s Python Client Library. So, I would

2条回答
  •  既然无缘
    2021-01-05 13:49

    Firefox (and other graphical browsers) require an X display. You can use a virtual one with the help of PyVirtualDisplay:

    from pyvirtualdisplay import Display
    display = Display(visible=0, size=(1024, 768))
    display.start()
    
    browser = webdriver.Firefox()
    ... more selenium code ...
    
    display.stop()
    

    Apart from PyVirtualDisplay, you'll also need its dependencies xfvb and Xephyr (on debian: apt-get install -y xvfb xserver-xephyr)

提交回复
热议问题