Skip to content

Instantly share code, notes, and snippets.

@daniel-butler
Created February 12, 2020 21:51
Show Gist options
  • Save daniel-butler/b7cd1af12f71ddb64c3e11ce86e9400b to your computer and use it in GitHub Desktop.
Save daniel-butler/b7cd1af12f71ddb64c3e11ce86e9400b to your computer and use it in GitHub Desktop.
Connecting selenium grid to flask app error
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hi():
return 'hello'
import pytest
from app import app as a
@pytest.fixture
def app():
app = a
return app
version: "3"
services:
app:
build:
context: .
dockerfile: deploy/app/Dockerfile
depends_on:
- selenium-hub
environment:
- FLASK_APP=api.py
- FLASK_ENV=development
volumes:
- ./src:/src
- ./tests:/tests
ports:
- "5000:5000"
stdin_open: true
command: bash -c "flask run --host 0.0.0.0"
selenium-hub:
image: selenium/hub:latest
ports:
- "4444:4444"
selenium-chrome:
image: selenium/node-chrome-debug
stdin_open: true
links:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
FROM python:3.8-buster
COPY ./requirements.txt /tmp/
RUN pip install --upgrade pip
RUN pip install -r /tmp/requirements.txt
RUN mkdir -p /src
COPY /src /src
RUN pip install -e /src
RUN mkdir -p /tests
COPY /tests /tests
WORKDIR /src
flask
# Testing
pytest
pytest-selenium
pytest-flask
import pytest
@pytest.fixture
def selenium(selenium, live_server):
yield selenium
selenium.close()
def test_opening_up_web_page(selenium):
# GIVEN the web page
selenium.get(f'http://localhost:5000')
# ->print(selenium.page_source) --> Error here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment