目前,我正在使用适用于Python的galen框架。我在虚拟机和galenpy中使用Python 2.7,Ubuntu 18.04。当我运行单元测试时,出现如下错误
MainThread - line:117 in remote_connection - Could not connect to port 4444 on host localhost
MainThread - line:136 in remote_connection - Could not get IP address for host: localhost
对该框架硒的要求, 鼻子2, gal 轮, 节约, pyhamcrest, 请求,我安装了所有请求,但我不知道我在哪里犯了错误。
import os
import unittest
from galenpy.galen_api import Galen
from galenpy.galen_report import TestReport, info_node, warn_node, error_node
from galenpy.galen_webdriver import GalenRemoteWebDriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class GalenTestBase(unittest.TestCase):
def __init__(self, methodName='runTest'):
super(GalenTestBase, self).__init__(methodName)
def setUp(self):
self.driver = GalenRemoteWebDriver("http://localhost:4444/wd/hub", desired_capabilities=DesiredCapabilities.FIREFOX)
def tearDown(self):
if self.driver:
self.driver.quit()
def check_layout(self, test_name, specs, included_tags, excluded_tags):
try:
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__) + '/..'))
test_report = TestReport(test_name)
check_layout_report = Galen().check_layout(self.driver, os.path.join(parent_dir, "test", "specs", specs),
included_tags, excluded_tags)
test_report.add_report_node(info_node("Running layout check for: " + test_name)
.with_node(warn_node('this is just an example'))
.with_node(error_node('to demonstrate reporting'))) \
.add_layout_report_node("check " + specs, check_layout_report).finalize()
if check_layout_report.errors > 0:
raise AssertionError(
"Incorrect layout: " + test_name + " - Number of errors " + str(check_layout_report.errors))
except Exception as e:
raise e
输出如下
Testing started at 10:34 ...
stdout listener - line:43 in remote_service_logging - starting listener for STDOUT
stderr listener - line:43 in remote_service_logging - starting listener for STDERR
Remote service - line:62 in remote_service_logging - starting Galen API Remote Service logger
MainThread - line:58 in remote_service_lifecycle - Started server at port 9092
Remote service - line:74 in remote_service_logging - [main] INFO galen.api.server.GalenApiServer - Starting server on port 9092
MainThread - line:117 in remote_connection - Could not connect to port 4444 on host localhost
MainThread - line:136 in remote_connection - Could not get IP address for host: localhost
Remote service - line:74 in remote_service_logging - [pool-1-thread-2] INFO galen.api.server.GalenApiServer - Setting up new WebDriver session
Remote service - line:74 in remote_service_logging - [pool-1-thread-2] ERROR galen.api.server.GalenApiServer - Could not reach browser at URL http://localhost:4444/wd/hub check remote server is running.
MainThread - line:47 in galen_webdriver - Could not reach browser at URL http://localhost:4444/wd/hub check remote server is running.
Remote service - line:74 in remote_service_logging - [pool-1-thread-4] INFO galen.api.server.GalenApiServer - Shutting down Galen API service.
Error
Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/case.py", line 320, in run
self.setUp()
File "/home/yuceturk/Desktop/galen-sample-py-tests-master/src/galen_test_base.py", line 31, in setUp
self.driver = GalenRemoteWebDriver("http://localhost:4444/wd/hub", desired_capabilities=DesiredCapabilities.FIREFOX)
File "/home/yuceturk/Desktop/galen-sample-py-tests-master/venv/local/lib/python2.7/site-packages/galenpy/galen_webdriver.py", line 49, in __init__
raise e
SessionNotCreatedException: Message: Could not reach browser at URL http://localhost:4444/wd/hub check remote server is running.
答案 0 :(得分:1)
我很久以前创建了那个项目。很高兴看到有人想从灰尘中挖掘出来。我看到可能需要一些工作才能对其进行更新。 至于您的问题,看来您不在本地主机上运行Selenium Grid。