Botium Box和Selenium(Docker)之间的通信问题

时间:2019-02-04 13:48:38

标签: selenium docker testing chatbot

我们在单独的docker容器中有一个运行中的botium-box和硒版本。 t盒连接到云中的redis和pyramida。 通过运行以下命令,我们使用网络连接了Docker容器:

docker run --name botium -p 4000:4000 botiumbox
docker run --name selenium --hostname selenium -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome:3.141.59-europium
docker network create my-net
docker network connect my-net selenium
docker network connect my-net botium

我们有一个使用botium-cli的聊天机器人的测试用例,如以下文章所述:https://chatbotsmagazine.com/5-steps-automated-testing-of-chatbots-in-eclipse-ef4c3dcaf233

当我们尝试将聊天机器人与botium-box连接时,会出现以下错误:

2019-02-04T13:06:44.665Z botium-box-server-agents-testsession Test Session Job 247/cjrqcmo4j00yt0807mskvflq9 failed: Error: <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="/assets/displayhelpservlet.css" media="all"/>
  <link href="/assets/favicon.ico" rel="icon" type="image/x-icon" />
  <script src="/assets/jquery-3.1.1.min.js" type="text/javascript"></script>
  <script src="/assets/displayhelpservlet.js" type="text/javascript"></script>
  <script type="text/javascript">
    var json = Object.freeze('{"consoleLink": "\u002fwd\u002fhub","type": "Standalone","class": "org.openqa.grid.web.servlet.DisplayHelpHandler$DisplayHelpServletConfig","version": "3.141.59"}');
  </script>
</head>
<body>

<div id="content">
  <div id="help-heading">
    <h1><span id="logo"></span></h1>
    <h2>Selenium <span class="se-type"></span>&nbsp;v.<span class="se-version"></span></h2>
  </div>

  <div id="content-body">
    <p>
      Whoops! The URL specified routes to this help page.
    </p>
    <p>
      For more information about Selenium <span class="se-type"></span> please see the
      <a class="se-docs">docs</a> and/or visit the <a class="se-wiki">wiki</a>.
      <span id="console-item">
        Or perhaps you are looking for the Selenium <span class="se-type"></span> <a class="se-console">console</a>.
      </span>
    </p>
    <p>
      Happy Testing!
    </p>
  </div>

  <div>
    <footer id="help-footer">
      Selenium is made possible through the efforts of our open source community, contributions from
      these <a href="https://github.com/SeleniumHQ/selenium/blob/master/AUTHORS">people</a>, and our
      <a href="http://www.seleniumhq.org/sponsors/">sponsors</a>.
   </footer>
  </div>
 </div>

</body>
</html>
    at new RuntimeError (/app/agent/node_modules/webdriverio/build/lib/utils/ErrorHandler.js:143:12)
    at Request._callback (/app/agent/node_modules/webdriverio/build/lib/utils/RequestHandler.js:302:39)
    at Request.self.callback (/app/agent/node_modules/request/request.js:185:22)
    at Request.emit (events.js:188:13)
    at Request.EventEmitter.emit (domain.js:439:20)
    at Request.<anonymous> (/app/agent/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:188:13)
    at Request.EventEmitter.emit (domain.js:439:20)
    at IncomingMessage.<anonymous> (/app/agent/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:276:13).

为什么我们会收到此重定向? Selenium端点(设备提供者)应使用哪个端点?

如何在Docker中连接Selenium和botium-box?

非常感谢您!

更新

这是我们肉毒杆菌毒素测试项目的配置 https://i.stack.imgur.com/1B5nP.jpg

https://i.stack.imgur.com/cnXLu.jpg

https://i.stack.imgur.com/8JtzM.jpg

更新2: 到目前为止,我们做了什么:

  1. 我们已将docker botium容器更新为最新版本(1.3.1)
  2. 我们通过从botium-cli测试用例中上传工作中的botium.json->不错的功能来配置一个新的聊天机器人:)

现在,我们仍然遇到上述相同的问题。我们发现以下行为。我们使用测试项目配置中的功能,并通过两种方式定义功能:

  1. 我们将“ WEBDRIVERIO_OPTIONS”用作功能#1,类型:JSON结构和值:
        {"desiredCapabilities": {
          "browserName": "chrome",
          "platformName": "Windows 10"     
        }
      }    
  1. 我们将“ desiredCapabilities”用作Capability#1,类型:JSON结构和值:
 {"browserName": "chrome", 
  "platformName": "Windows 10"      
 }

运行测试后,我们通过以下日志恢复了上述错误:

  1. 我们的配置丢失
"botium":{  
     "Capabilities":{  
        "PROJECTNAME":"Conversation Sample",
        "SCRIPTING_FORMAT":"xlsx",
        "SCRIPTING_XLSX_STARTROW":2,
        "SCRIPTING_XLSX_STARTCOL":1,
        "CONTAINERMODE":"webdriverio",
        "WEBDRIVERIO_START_PHANTOMJS":false,
        "WEBDRIVERIO_URL":"url removed",
        "WEBDRIVERIO_INPUT_ELEMENT":"#bot-input",
        "WEBDRIVERIO_OUTPUT_ELEMENT":"//div[@class=\"messages__message messages__message--received\"]//span[@class=\"content__text\" and not(contains(.,\"...\"))]",
        "WEBDRIVERIO_OPTIONS":{  
           "desiredCapabilities":{  
              "name":"Test Project- Test Session"
           },
           "protocol":"http",
           "host":"172.21.0.2:4444",
           "port":"4444",
           "path":"/wd/hub"
        },
        "WEBDRIVERIO_IGNOREUPFRONTMESSAGES":true,
        "WEBDRIVERIO_OPENBOTPAUSE":4000,
        "WEBDRIVERIO_PROFILE":"",
        "WEBDRIVERIO_INPUT_ELEMENT_VISIBLE_TIMEOUT":10000,
        "WEBDRIVERIO_USERNAME":"",
        "WEBDRIVERIO_PASSWORD":"",
        "WEBDRIVERIO_SCREENSHOTS":"none",
        "FBPAGERECEIVER_REDISURL":{  
           "port":"6379",
           "host":"redis",
           "db":0,
           "options":{  

           }
        }
     },
     "Sources":{  

     },
     "Envs":{  

     }
  },
  1. 我们的配置错误级别
"botium":{  
      "Capabilities":{  
         "PROJECTNAME":"Conversation Sample",
         "SCRIPTING_FORMAT":"xlsx",
         "SCRIPTING_XLSX_STARTROW":2,
         "SCRIPTING_XLSX_STARTCOL":1,
         "CONTAINERMODE":"webdriverio",
         "WEBDRIVERIO_START_PHANTOMJS":false,
         "WEBDRIVERIO_URL":"url removed",
         "WEBDRIVERIO_INPUT_ELEMENT":"#bot-input",
         "WEBDRIVERIO_OUTPUT_ELEMENT":"//div[@class=\"messages__message messages__message--received\"]//span[@class=\"content__text\" and not(contains(.,\"...\"))]",
         "WEBDRIVERIO_OPTIONS":{  
            "desiredCapabilities":{  
               "name":"Test Project - Test Session"
            },
            "protocol":"http",
            "host":"172.21.0.2:4444",
            "port":"4444",
            "path":"/wd/hub"
         },
         "WEBDRIVERIO_IGNOREUPFRONTMESSAGES":true,
         "WEBDRIVERIO_OPENBOTPAUSE":4000,
         "WEBDRIVERIO_PROFILE":"",
         "WEBDRIVERIO_INPUT_ELEMENT_VISIBLE_TIMEOUT":10000,
         "WEBDRIVERIO_USERNAME":"",
         "WEBDRIVERIO_PASSWORD":"",
         "WEBDRIVERIO_SCREENSHOTS":"none",
         "desiredCapabilities":"{\"browserName\": \"chrome\",\"platformName\": \"Windows 10\"}",
         "FBPAGERECEIVER_REDISURL":{  
            "port":"6379",
            "host":"redis",
            "db":0,
            "options":{  

            }
         }
      },
      "Sources":{  

      },
      "Envs":{  

      }
   },

更新3:

version: '2'
services:
  web:
    image: botium/botium-box-ce:box-1.4.0
    ports:
     - "4000:4000"
    environment:
      PRISMA_ENDPOINT: http://prisma:4467/box/ce
      BOTIUMBOX_QUEUE_REDISURL: redis://redis:6379
      DEBUG: botium*
    depends_on:
      - redis
      - prisma
    volumes:
      - testsets:/app/server/testsets
      - botiumwork:/app/server/botiumwork
      - botiumwork:/app/agent/botiumwork
  prisma:
    image: prismagraphql/prisma:1.25.4
    depends_on:
      - mysql
    restart: always
    ports:
    - "4467:4467"
    environment:
      PRISMA_CONFIG: |
        port: 4467
        databases:
          default:
            connector: mysql
            host: mysql
            port: 3306
            user: root
            password: prisma
            migrations: true
  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - mysql:/var/lib/mysql
  redis:
    image: redis:alpine
    restart: always
    ports:
    - "6379:6379"
  selenium-hub:
    image: selenium/hub:3.141.59-mercury
    container_name: selenium-hub
    ports:
      - "4444:4444"
  chrome:
    image: selenium/node-chrome:3.141.59-mercury
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
  firefox:
    image: selenium/node-firefox:3.141.59-mercury
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
volumes:
  mysql:
  testsets:
  botiumwork:

1 个答案:

答案 0 :(得分:0)

Botium功能 Webdriver功能不同(尽管这是相同的概念)。 移交给Selenium的功能已封装在Botium功能WEBDRIVERIO_OPTIONS中-botium.json看起来像这样:

{
  "botium": {
    "Capabilities": {
      "PROJECTNAME": "WebdriverIO Plugin Sample",
      "CONTAINERMODE": "webdriverio",
      "WEBDRIVERIO_OPTIONS": {  
        "desiredCapabilities": {
          "browserName": "chrome"      
        }
      },
      ...
    }
  }
}

有关如何配置Webdriver连接器的详细信息,请参见Github存储库: https://github.com/codeforequity-at/botium-connector-webdriverio

在Botium Box中的配置与此类似,您可以在其中导入botium.json,或仅逐行配置功能。<​​/ p>

更新2019/05/18

事实证明,所描述的行为是Botium Box中的错误,将在下一版本中修复。我们在记录如何连接到自己的Selenium Grid方面做了一些工作: