51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2581|回复: 2
打印 上一主题 下一主题

[原创] 远程服务器控制浏览器一直报错 [WinError 10061]

[复制链接]
  • TA的每日心情
    无聊
    2016-8-9 16:39
  • 签到天数: 9 天

    连续签到: 1 天

    [LV.3]测试连长

    跳转到指定楼层
    1#
    发表于 2016-6-16 12:12:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    用的是python+selenium server

    程序如下:
    #coding=utf-8
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support.ui import Select
    from selenium.common.exceptions import NoSuchElementException
    import unittest, time, re
    from Public import login
    from Public import url
    import xml.dom.minidom
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    from selenium.webdriver import Remote


    #引入xml文件
    dom=xml.dom.minidom.parse('C:\\Python34\\enbrel_login\\data\\info.xml')
    root=dom.documentElement

    class EnbrelLogin(unittest.TestCase):
        def setUp(self):
            self.driver = url.browser(self)
            self.driver.implicitly_wait(30)
            #url,调用url.py
            self.base_url = url.url(self)
            self.verificationErrors = []
            self.accept_next_alert = True
            
        def test_enbrel_login(self):
            driver=self.driver
            driver.get(self.base_url)
            #登录,调用登录函数
            login.test_enbrel_login(self)
            #断言登录成功
            username=driver.find_element_by_id("dropdown-menu-head1").text
            self.assertEqual("Yi, Alina ",username)
            #退出,调用登录函数
            login.test_enbrel_logout(self)
        def tearDown(self):
            self.driver.quit()
            self.assertEqual([], self.verificationErrors)

    if __name__ == "__main__":
        unittest.main()

    调用模块1
    import xml.dom.minidom
    from selenium import webdriver
    from selenium.webdriver import Remote
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    dom=xml.dom.minidom.parse('C:\\Python34\\enbrel_login\\data\\info.xml')
    root=dom.documentElement
    #读取url信息
    url=root.getElementsByTagName("url")
    geturl=url[0].firstChild.data

    #读取浏览器信息
    bb=root.getElementsByTagName('browser')
    b=bb[0].firstChild.data

    def url(self):
        return geturl

    def browser(self):
        driver=webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                                desired_capabilities={'platform':'ANY',
                                                      'browserName':b,
                                                      'version':'',
                                                      'javascriptEnabled':True,
                                                      })
        return driver

    调用模块2
    #coding=utf-8
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    import unittest, time

    import xml.dom.minidom
    #引入xml文件
    dom=xml.dom.minidom.parse('C:\\Python34\\enbrel_login\\data\\info.xml')
    root=dom.documentElement
    #登录用户名和密码
    bb=root.getElementsByTagName('login')
    b=bb[0]
    username=b.getAttribute("username")
    password=b.getAttribute("password")

    #登录  
    def test_enbrel_login(self):
       
        driver = self.driver
        driver.find_element_by_id('username').clear()
        driver.find_element_by_id('username').send_keys(username)
        driver.find_element_by_id("password").clear()
        driver.find_element_by_id("password").send_keys(password)
        driver.find_element_by_id("btnLogin").click()
        time.sleep(2)
       
    #退出
    def test_enbrel_logout(self):
       
        driver=self.driver
        driver.find_element_by_xpath("//a[@id='dropdown-menu-head1']/span").click()
        driver.find_element_by_link_text("Logout").click()

    一直报错

    ======================================================================
    ERROR: test_enbrel_login (__main__.EnbrelLogin)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "C:\Python34\lib\urllib\request.py", line 1183, in do_open
        h.request(req.get_method(), req.selector, req.data, headers)
      File "C:\Python34\lib\http\client.py", line 1137, in request
        self._send_request(method, url, body, headers)
      File "C:\Python34\lib\http\client.py", line 1182, in _send_request
        self.endheaders(body)
      File "C:\Python34\lib\http\client.py", line 1133, in endheaders
        self._send_output(message_body)
      File "C:\Python34\lib\http\client.py", line 963, in _send_output
        self.send(msg)
      File "C:\Python34\lib\http\client.py", line 898, in send
        self.connect()
      File "C:\Python34\lib\http\client.py", line 871, in connect
        self.timeout, self.source_address)
      File "C:\Python34\lib\socket.py", line 516, in create_connection
        raise err
      File "C:\Python34\lib\socket.py", line 507, in create_connection
        sock.connect(sa)
    ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\Python34\enbrel_login\login_case\enbrel_login.py", line 29, in setUp
        self.driver = url.browser(self)
      File "C:\Python34\enbrel_login\login_case\Public\url.py", line 23, in browser
        'javascriptEnabled':True,
      File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 90, in __init__
        self.start_session(desired_capabilities, browser_profile)
      File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 177, in start_session
        response = self.execute(Command.NEW_SESSION, capabilities)
      File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 234, in execute
        response = self.command_executor.execute(driver_command, params)
      File "C:\Python34\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 401, in execute
        return self._request(command_info[0], url, body=data)
      File "C:\Python34\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 469, in _request
        resp = opener.open(request, timeout=self._timeout)
      File "C:\Python34\lib\urllib\request.py", line 464, in open
        response = self._open(req, data)
      File "C:\Python34\lib\urllib\request.py", line 482, in _open
        '_open', req)
      File "C:\Python34\lib\urllib\request.py", line 442, in _call_chain
        result = func(*args)
      File "C:\Python34\lib\urllib\request.py", line 1211, in http_open
        return self.do_open(http.client.HTTPConnection, req)
      File "C:\Python34\lib\urllib\request.py", line 1185, in do_open
        raise URLError(err)
    urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>

    在网上找了很久,都没解决,有人知道吗?


    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    2019-12-31 08:59
  • 签到天数: 975 天

    连续签到: 1 天

    [LV.10]测试总司令

    2#
    发表于 2016-6-17 09:31:20 | 只看该作者
    ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it  
    activity 不能访问?

    评分

    参与人数 1测试积点 +10 收起 理由
    lsekfe + 10 积极回复获得测试积点10

    查看全部评分

    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    郁闷
    2017-12-18 16:41
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    3#
    发表于 2017-12-6 18:01:29 | 只看该作者
    楼主,问题解决了吗?我也遇到同样的问题,其实目标计算机可以连接成功的。
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-4-27 07:07 , Processed in 0.064554 second(s), 25 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表