Selenium(Docker,python,behave)在CI中需要数小时才能完成

时间:2018-04-04 19:31:34

标签: selenium docker docker-compose python-behave

测试是用python行为编写的,并使用Docker执行。在Mac / Windows / Linux本地,所有110个测试步骤使用相同的站点在4分钟内完成,而在CI代理(AWS)上则需要120-160分钟。视频显示浏览器在步骤之间旋转约4分钟。有没有办法调试selenium以找出加载缓慢的资源?

Selenium DEBUG日志记录没有帮助。提交后,需要4分钟才能完成POST请求:

JsonConverter

docker-compose.yml:

04-Apr-2018 20:13:01    DEBUG:selenium.webdriver.remote.remote_connection:POST http://127.0.0.1:4444/wd/hub/session/a6975e2107e574693fb48f21420c1850/element {"using": "id", "value": "submit", "sessionId": "a6975e2107e574693fb48f21420c1850"}
04-Apr-2018 20:13:01    DEBUG:selenium.webdriver.remote.remote_connection:Finished Request
04-Apr-2018 20:13:01    DEBUG:selenium.webdriver.remote.remote_connection:POST http://127.0.0.1:4444/wd/hub/session/a6975e2107e574693fb48f21420c1850/element/0.7198908368495902-4/click {"id": "0.7198908368495902-4", "sessionId": "a6975e2107e574693fb48f21420c1850"}
04-Apr-2018 20:17:00    DEBUG:selenium.webdriver.remote.remote_connection:Finished Request

Dockerfile:

version: '3.4'

services:
  test:
    build:
      context: .
    image: qa-automation
    network_mode: host
    environment:
      LOCAL: "false"
      BROWSER: "${TEST_BROWSER:-chrome}"
      SERVER: "${TEST_URL:-https://example.com}"

  selenium:
    image: elgalu/selenium:3.11.0-p5
    shm_size: 2g 
    ports:
      - 4444:24444
      - 6000:25900
    environment:
      SCREEN_WIDTH: 1920
      SCREEN_HEIGHT: 1080
      TZ: "US/Central"
      VIDEO_FILE_NAME: "${TEST_BROWSER:-chrome}"
    volumes:
      - ./target/videos:/videos

requirements.txt:

FROM python:3.6.4-alpine3.7

# Install utilities
RUN apk --update --no-cache add bash curl git && rm -rf /var/cache/apk/*

ENV PYTHONUNBUFFERED 1
WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

# see .dockerignore
COPY . .

ENTRYPOINT ["bin/docker-entrypoint.sh"]
CMD ["behave"]

test.sh:

appdirs==1.4.3
behave==1.2.6
packaging==16.8
pyparsing==2.2.0
requests==2.13.0
selenium==3.11.0
six==1.11.0

0 个答案:

没有答案