2

我想在不打开浏览器的情况下运行 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'

因为我是新手,所以我不知道我出了什么问题?

4

0 回答 0