add selenium test
This commit is contained in:
parent
20b09f7b39
commit
af470c0ecd
|
@ -49,6 +49,11 @@ jobs:
|
|||
python -m pip install --upgrade pip
|
||||
pip install flake8 pytest coverage
|
||||
pip install -r requirements.txt
|
||||
alembic -x inventory=dbtest upgrade head
|
||||
dh dummy --yes
|
||||
mkdir bin
|
||||
wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
|
||||
tar xf geckodriver-v0.30.0-linux64.tar.gz -C bin/
|
||||
|
||||
- name: Prepare database
|
||||
env:
|
||||
|
@ -79,6 +84,7 @@ jobs:
|
|||
coverage run --source='ereuse_devicehub' -m pytest -m mvp --maxfail=5 tests/
|
||||
coverage report --include='ereuse_devicehub/*'
|
||||
coverage xml
|
||||
flask run & pytest tests/test_selenium.py
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
# Generated by Selenium IDE
|
||||
import time
|
||||
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.firefox.options import Options
|
||||
|
||||
|
||||
class TestSelenium:
|
||||
def setup_method(self, method):
|
||||
options = Options()
|
||||
options.add_argument("--headless")
|
||||
self.driver = webdriver.Firefox(
|
||||
options=options, executable_path=r'./bin/geckodriver'
|
||||
)
|
||||
self.vars = {}
|
||||
|
||||
def teardown_method(self, method):
|
||||
self.driver.quit()
|
||||
|
||||
def test_selenium(self):
|
||||
# setup
|
||||
self.driver.get("http://localhost:5000/login/")
|
||||
self.driver.set_window_size(1920, 1063)
|
||||
|
||||
# login
|
||||
self.driver.find_element(By.ID, "yourEmail").click()
|
||||
self.driver.implicitly_wait(3)
|
||||
self.driver.find_element(By.ID, "yourPassword").send_keys("1234")
|
||||
self.driver.find_element(By.ID, "yourEmail").send_keys("user@dhub.com")
|
||||
self.driver.find_element(By.CSS_SELECTOR, ".btn").click()
|
||||
self.driver.implicitly_wait(3)
|
||||
|
||||
# select the first lot and get the ID of it
|
||||
self.driver.find_element(By.LINK_TEXT, "Temporary Lots").click()
|
||||
self.driver.implicitly_wait(3)
|
||||
self.driver.find_element(
|
||||
By.CSS_SELECTOR, "#temporal-lots-nav > li:nth-child(2) span"
|
||||
).click()
|
||||
self.driver.implicitly_wait(3)
|
||||
lot_id = self.driver.current_url.split("/")[5]
|
||||
|
||||
# go to unassigned
|
||||
self.driver.find_element(By.CSS_SELECTOR, ".nav-item:nth-child(3) span").click()
|
||||
self.driver.implicitly_wait(3)
|
||||
|
||||
# select the first device
|
||||
self.driver.find_element(
|
||||
By.CSS_SELECTOR, "tr:nth-child(1) .deviceSelect"
|
||||
).click()
|
||||
self.driver.implicitly_wait(3)
|
||||
|
||||
# add to new selenium_lot
|
||||
self.driver.find_element(By.ID, "btnLots").click()
|
||||
self.driver.implicitly_wait(3)
|
||||
self.driver.find_element(By.ID, lot_id).click()
|
||||
self.driver.implicitly_wait(3)
|
||||
self.driver.find_element(By.ID, "ApplyDeviceLots").click()
|
||||
time.sleep(3)
|
||||
self.driver.find_element(By.ID, "SaveAllActions").click()
|
||||
time.sleep(3)
|
||||
|
||||
# go to selenium lot
|
||||
self.driver.find_element(By.LINK_TEXT, "Temporary Lots").click()
|
||||
self.driver.implicitly_wait(3)
|
||||
self.driver.find_element(
|
||||
By.CSS_SELECTOR, "#temporal-lots-nav > li:nth-child(2) span"
|
||||
).click()
|
||||
self.driver.implicitly_wait(3)
|
||||
|
||||
# select the first device
|
||||
self.driver.find_element(By.CSS_SELECTOR, ".deviceSelect").click()
|
||||
|
||||
# remove to new selenium_lot
|
||||
self.driver.find_element(By.ID, "btnLots").click()
|
||||
self.driver.implicitly_wait(3)
|
||||
self.driver.find_element(By.ID, lot_id).click()
|
||||
self.driver.implicitly_wait(3)
|
||||
self.driver.find_element(By.ID, "ApplyDeviceLots").click()
|
||||
time.sleep(3)
|
||||
self.driver.find_element(By.ID, "SaveAllActions").click()
|
||||
time.sleep(3)
|
||||
|
||||
self.driver.find_element(By.CSS_SELECTOR, ".nav-item:nth-child(3) span").click()
|
||||
self.driver.implicitly_wait(3)
|
||||
|
||||
# logout
|
||||
self.driver.find_element(By.CSS_SELECTOR, ".d-md-block").click()
|
||||
self.driver.implicitly_wait(3)
|
||||
self.driver.find_element(By.LINK_TEXT, "Sign Out").click()
|
Reference in New Issue