1

我在运行 selenium 代码时使用 selenium,但出现错误:

WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: cannot open display: IP:192.168.72.112\n'

我正在通过腻子运行我的代码,因为腻子中没有显示。我使用了虚拟显示的概念并安装了“pyvirtualdisplay”模块。在运行脚本之前,我有以下命令:

export DISPLAY='IP:191.168.72.112'

但仍然无法运行...请帮助我并建议我,我做错了什么?

Python硒代码:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
from pyvirtualdisplay import Display

class PSeleTry1(unittest.TestCase):
    def setUp(self):
        display = Display(visible=0, size=(1024, 768))
        display.start()
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(30)
        self.base_url = "http://www.example.com/"
        ......
        .....// remaining code generated by selenium ide//
4

0 回答 0