Селен тесты не пройдены на CircleCI - PullRequest
0 голосов
/ 25 мая 2018

У меня есть приложение Django, которое я пытаюсь тестировать Selenium на CircleCI, но даже при том, что они локально работают в моей тестовой среде, они продолжают давать сбой с NoSuchElementException от Selenium на CircleCI.

В началеВ большинстве моих браузерных тестов я запускаю следующий метод, который делает тесты неудачными:

def login():
  driver.get(self.live_server_url + reverse("login"))
  # FAILURE HAPPENS HERE: Not able to find the `id_email` element
  driver.find_element_by_id("id_email").send_keys(u.email)
  driver.find_element_by_id("id_password").send_keys("12345678")
  driver.find_element_by_id("submit-login").click()

config.yml

version: 2
jobs:
  build:
    docker:
      - image: circleci/python:3.6.5-node-browsers
        environment:
          CI_TESTING: 1    
      - image: redis

    working_directory: ~/repo

    steps:
      - checkout

      # Selenium setup
      - run: mkdir test-reports
      - run:
          name: Download Selenium
          command: |
            curl -O http://selenium-release.storage.googleapis.com/3.5/selenium-server-standalone-3.5.3.jar
      - run:
          name: Start Selenium
          command: |
            java -jar selenium-server-standalone-3.5.3.jar -log test-reports/selenium.log
          background: true

      - restore_cache:
          name: Restore Pip Package Cache
          keys:
          - v1-dependencies-{{ checksum "requirements.txt" }}
          - v1-dependencies-
      - run:
          name: Install Pip Dependencies
          command: |
            python3 -m venv venv
            . venv/bin/activate
            pip install -r requirements.txt
      - save_cache:
          name: Save Pip Package Cache
          key: v1-dependencies-{{ checksum "requirements.txt" }}
          paths:
            - ./venv

      - restore_cache:
          name: Restore Yarn Package Cache
          keys:
            - yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
            - yarn-packages-{{ .Branch }}
            - yarn-packages-master
            - yarn-packages-
      - run:
          name: Install Yarn Dependencies
          command: |
            yarn install
      - save_cache:
          name: Save Yarn Package Cache
          key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
          paths:
            - node_modules/

      - run:
          name: Run Django Tests
          command: |
            . venv/bin/activate
            ./test.sh

      - store_artifacts:
          path: test-reports
          destination: test-reports

Определение драйвера:

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("headless")
drive = webdriver.Chrome(chrome_options=chrome_options)

Неправильно ли настроен мой CircleCI?Я просмотрел несколько страниц в документации, и мне все это кажется правильным.

https://circleci.com/docs/2.0/project-walkthrough/#install-and-run-selenium-to-automate-browser-testing https://github.com/CircleCI-Public/circleci-demo-python-flask/blob/master/.circleci/config.yml#L16:7 https://circleci.com/docs/2.0/browser-testing/

...