Created
February 12, 2020 21:51
-
-
Save daniel-butler/b7cd1af12f71ddb64c3e11ce86e9400b to your computer and use it in GitHub Desktop.
Connecting selenium grid to flask app error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/') | |
def hi(): | |
return 'hello' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from app import app as a | |
@pytest.fixture | |
def app(): | |
app = a | |
return app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flask | |
# Testing | |
pytest | |
pytest-selenium | |
pytest-flask |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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