From d15c793078b29147b4eaba816ccd01295748766c Mon Sep 17 00:00:00 2001 From: Carlos Kidman Date: Fri, 21 Oct 2022 09:50:14 -0600 Subject: [PATCH 1/2] add gitpod files --- .gitpod.Dockerfile | 51 +++++++++++++++++++++++++++++++++++++++++++ .gitpod.yml | 22 +++++++++++++++++++ .vscode/settings.json | 17 ++++++++++++++- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 .gitpod.Dockerfile create mode 100644 .gitpod.yml diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 0000000..5e0048a --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,51 @@ +FROM gitpod/workspace-full-vnc + +USER root + +# RUN apt-get update -qqy && apt-get install -y wget curl gnupg2 + +# So we can install browsers and browser drivers later +RUN wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \ + && dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ + echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list +RUN mkdir -p /home/gitpod/selenium /var/run/supervisor /var/log/supervisor && \ + chmod -R 777 /var/run/supervisor /var/log/supervisor + +ENV DEBIAN_FRONTEND=noninteractive + +# Browsers +RUN apt-get update -qqy && \ + apt-get -qy install google-chrome-stable firefox && \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +# Browser Drivers +RUN CHROME_MAJOR_VERSION=$(google-chrome --version | sed -E "s/.* ([0-9]+)(\.[0-9]+){3}.*/\1/") \ + && CHROME_DRIVER_VERSION=$(wget --no-verbose -O - "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION}") \ + && echo "Using ChromeDriver version: "$CHROME_DRIVER_VERSION \ + && wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \ + && rm -rf /home/gitpod/selenium/chromedriver \ + && unzip /tmp/chromedriver_linux64.zip -d /home/gitpod/selenium \ + && rm /tmp/chromedriver_linux64.zip \ + && mv /home/gitpod/selenium/chromedriver /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION \ + && chmod 755 /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION \ + && sudo ln -fs /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver +RUN GK_VERSION="0.31.0" \ + && echo "Using GeckoDriver version: "$GK_VERSION \ + && wget --no-verbose -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v$GK_VERSION/geckodriver-v$GK_VERSION-linux64.tar.gz \ + && rm -rf /home/gitpod/selenium/geckodriver \ + && tar -C /home/gitpod/selenium -zxf /tmp/geckodriver.tar.gz \ + && rm /tmp/geckodriver.tar.gz \ + && mv /home/gitpod/selenium/geckodriver /home/gitpod/selenium/geckodriver-$GK_VERSION \ + && chmod 755 /home/gitpod/selenium/geckodriver-$GK_VERSION \ + && ln -fs /home/gitpod/selenium/geckodriver-$GK_VERSION /usr/bin/geckodriver + +# To run browser tests +ENV DISPLAY :99.0 +ENV DISPLAY_NUM 99 +ENV SCREEN_WIDTH 1360 +ENV SCREEN_HEIGHT 1020 +ENV SCREEN_DEPTH 24 +ENV SCREEN_DPI 96 +ENV VNC_PORT 5900 +ENV NO_VNC_PORT 7900 diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..1db13d4 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,22 @@ +vscode: + extensions: + - ms-python.python + - bungcip.better-toml + - PKief.material-icon-theme + +image: + file: .gitpod.Dockerfile + +tasks: + - name: "Setup" + command: | + git config --global pull.rebase false + pip install poetry + poetry install +ports: + - port: 5900 + onOpen: ignore + - port: 6080 + onOpen: open-browser + - port: 10000 + onOpen: ignore diff --git a/.vscode/settings.json b/.vscode/settings.json index d969f96..0b0ee0e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,20 @@ { "python.testing.pytestArgs": ["tests"], + "python.defaultInterpreterPath": ".venv/bin/python", "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true + "python.testing.pytestEnabled": true, + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/Thumbs.db": true, + "**/*.crswap": true, + "**/*.pytest_cache": true, + "**/*__pycache__": true + }, + "python.linting.enabled": true, + "python.formatting.provider": "black", + "workbench.iconTheme": "material-icon-theme" } From 22590c3863cab3beff12d566aa7bbf0cc10c7cc3 Mon Sep 17 00:00:00 2001 From: Carlos Kidman Date: Fri, 21 Oct 2022 16:40:41 +0000 Subject: [PATCH 2/2] add gitpod details to README --- README.md | 29 +++++++++++++++++++++++++++++ pytest.ini | 2 ++ 2 files changed, 31 insertions(+) diff --git a/README.md b/README.md index d5bed70..e64ed08 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ # Pylenium: Easy Python Web Test Automation +- [The Mission](#the-mission-is-simple) + - [Test Example](#test-example) + - [Purpose](#purpose) +- [Quickstart](#quick-start) + - [1. Install](#1-install-pyleniumio) + - [2. Initialize](#2-initialize-pylenium) + - [3. Write a Test](#3-write-a-test) + - [4. Run the Test](#4-run-the-test) +- [Contribute](#contribute) + + ## The mission is simple > Bring the best of Selenium, Cypress and Python into one package. @@ -143,3 +154,21 @@ python -m pytest tests/test_google.py ``` You're all set! You should see the browser open and complete the commands we had in the test :\) + +## Contribute + +Pylenium uses [Gitpod](https://gitpod.io/) to make it easy to work on it from the _desktop or browser_ without having to worry about the setup like having the correct Python version installed after cloning the repo. + +> ๐Ÿ’ก With a single click, you can open the repo in your browser, make your changes, then submit a pull request! + +0. If you're new to Gitpod, check out their [Getting Started](https://www.gitpod.io/docs/introduction/getting-started) docs to see how to use it +1. Visit [Pylenium's repo](https://github.com/ElSnoMan/pyleniumio) and click the `Gitpod` button to open the repo in a VS Code browser window +2. Wait for Gitpod to setup the project. You'll see things get setup from the various `.gitpod*` files at the Project Root +3. Once complete, create a new branch and start making your changes +4. When ready, submit a Pull Request! +5. Reviewers will see your CI pipeline and even be able to open your Gitpod instance if needed - making collaboration much easier +6. Gitpod instances are ephemeral, so you can create, share, and delete them as needed + +> ๐Ÿงช By default, UI tests executed in Gitpod are headless. If you'd like to see UI tests run, open port `6080` from the bottom right corner of VS Code. + +For more details and other ways to contribute to Pylenium, visit the [CONTRIBUTING.md](/CONTRIBUTING.md) doc ๐Ÿ‘€ diff --git a/pytest.ini b/pytest.ini index 5b080f7..f482e23 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,6 +1,8 @@ [pytest] ; Configuring pytest ; More info: https://docs.pytest.org/en/6.2.x/customize.html +testpaths = + tests ;Logging ; DATE FORMAT EXAMPLE: %Y-%m-%d %H:%M:%S