This adds some user integration tests to aide the SoftVision team a bit. Right now I have 3 tests.

test_upload: This will create a file and make sure it uploads by verifying a file uploads and is assigned a URL.

    test_download: This will create a file, upload it and then download it making sure it is the same filename that was uploaded. We can expand this later to maybe check the sizes and such.

    test_progress: This will create a file and make sure the progress bar shows up after it begins uploading.

    These are python tests and use Pipenv to manage dependencies as well as tox as the virtualenv manager, and finally pytest as the test runner.
This commit is contained in:
Benjamin Forehand Jr 2018-04-24 11:00:19 -04:00
parent 464c0c4c47
commit 54e78b6274
21 changed files with 398 additions and 4 deletions

View file

View file

@ -0,0 +1,18 @@
from pypom import Page
from selenium.webdriver.common.by import By
class Base(Page):
_url = '{base_url}'
_send_logo_locator = (By.CLASS_NAME, 'logo')
def __init__(self, selenium, base_url, locale='en-US', **kwargs):
super(Base, self).__init__(
selenium, base_url, locale=locale, timeout=10, **kwargs)
def wait_for_page_to_load(self):
self.wait.until(
lambda _: self.find_element(
*self._send_logo_locator).is_displayed())
return self

View file

@ -0,0 +1,16 @@
from selenium.webdriver.common.by import By
from pages.desktop.base import Base
class Download(Base):
_download_button_locator = (By.CLASS_NAME, 'btn--download')
def wait_for_page_to_load(self):
self.wait.until(lambda _: self.download_btn.is_displayed())
@property
def download_btn(self):
"""Download button."""
return self.find_element(*self._download_button_locator)

View file

@ -0,0 +1,26 @@
from selenium.webdriver.common.by import By
from pages.desktop.base import Base
class Home(Base):
"""Addons Home page"""
_upload_area_locator = (By.ID, 'file-upload')
_upload_button_locator = (By.CLASS_NAME, 'btn--file')
@property
def upload_btn(self):
"""Upload button."""
return self.find_element(*self._upload_button_locator)
def upload_area(self, path, cancel=False):
"""Area that allows for drag and drop uploading.
Returns Progress Object.
"""
self.find_element(*self._upload_area_locator).send_keys(path)
from pages.desktop.progress import Progress
return Progress(
self.selenium, self.base_url).wait_for_page_to_load(
cancel_after_load=cancel)

View file

@ -0,0 +1,24 @@
from selenium.webdriver.common.by import By
from pages.desktop.base import Base
class Progress(Base):
_cancel_button = (By.ID, 'cancel-upload')
_progress_icon_locator = (By.CLASS_NAME, 'progress__bar')
def wait_for_page_to_load(self, cancel_after_load=False):
self.wait.until(
lambda _: self.find_element(
*self._progress_icon_locator).is_displayed())
if cancel_after_load:
self.cancel_btn.click()
return
from pages.desktop.share import Share
return Share(self.selenium, self.base_url).wait_for_page_to_load()
@property
def cancel_btn(self):
"""Cancel upload button."""
return self.find_element(*self._cancel_button)

View file

@ -0,0 +1,21 @@
from selenium.webdriver.common.by import By
from pages.desktop.base import Base
class Share(Base):
_share_page_locator = (By.CLASS_NAME, 'sharePage')
_share_url_locator = (By.ID, 'fileUrl')
def wait_for_page_to_load(self):
self.wait.until(
lambda _: self.find_element(
*self._share_page_locator).is_displayed())
return self
@property
def file_url(self):
"""File uploaded URL."""
return self.find_element(
*self._share_url_locator).get_property('value')