小编sym*_*ech的帖子

selenium.common.exceptions.WebDriverException:消息:'无法连接到GhostDriver'

我试图运行PhantomJS从内selenium.webdriverCentOS的服务器上.PhantomJS在路径中并且从终端正常运行.但是在脚本中它似乎已启动,但之后无法在指定端口上到达(我尝试了2个不同的打开端口,来自我的提供程序29842和60099,它们都不工作,并且没有指定端口也没有启动它).

错误发生在selenium.webdriver.common.utils:

try:
    socket_ = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    socket_.settimeout(1)
    socket_.connect(("localhost", port))
    socket_.close()
    return True
except socket.error:
    return False
Run Code Online (Sandbox Code Playgroud)

这是从我的脚本(我尝试没有任何参数,以及编写可执行文件的完整路径,但都没有工作):

self.browser = webdriver.PhantomJS(
            port=29842,
            desired_capabilities={
                'javascriptEnabled': True,
                'platform': 'windows',
                'browserName': 'Mozilla',
                'version': '5.0',
                'phantomjs.page.settings.userAgent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36"
            }
        )
Run Code Online (Sandbox Code Playgroud)

这是初始化webdriver的脚本selenium.webdriver.phantomjs.service.我检查并subprocess.Popen实际上lauches phantomjs,错误发生在while循环:

    try:
        self.process = subprocess.Popen(self.service_args,
                                        stdout=self._log, stderr=self._log)

    except Exception as e:
        raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)

    count = 0 …
Run Code Online (Sandbox Code Playgroud)

python port phantomjs selenium-webdriver ghostdriver

17
推荐指数
1
解决办法
2万
查看次数

每个模型覆盖django admin change_list_results.html

我试图change_list_results.html仅覆盖特定模型.我尝试将文件复制到相应树目录(templates/admin/APP/MODEL)中的其他模板,但此方法不起作用.我在文档中看到,每个应用程序/模型都可以覆盖,但是没有描述实现此目的的特殊方法.我找到了一些关于覆盖change_list.html的相关答案,但我想只覆盖change_list_results.html,我无法理解如何实现这一目标.覆盖的方法是什么?

django django-templates django-admin

6
推荐指数
1
解决办法
1679
查看次数