我想在不打开浏览器的情况下运行python selenium脚本。我在rhel上安装了xvfbwrapper-0.1.3,并编辑了我的代码:
from selenium import webdriver,selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time
from xvfbwrapper import Xvfb
class SeleTry(unittest.TestCase):
def setUp(self):
try:
vdisplay = Xvfb(width=1280, height=720)
vdisplay.start()
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(10)
.....//rest of the code//
当我试图执行它时,它正在抛出一个皇帝:
'The browser appears to have exited before we could connect. The output was: Error: cannot open display: :1013\n'
由于我是新手,我不知道我错了什么?