Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/source/contrib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ If you want to install this package with support for all CONTRIB packages, you c

>>> pip install balderhub-html[all]

Contrib for ``balderhub-auth``
==============================

For activating this module, you need to install the package like shown below

.. code-block:: none

>>> pip install balderhub-html[auth]

Once installed you can use it.

Pages
-----

.. autoclass:: balderhub.html.contrib.auth.pages.LoginPage
:members:


Setup Features
--------------

.. autoclass:: balderhub.html.contrib.auth.setup_features.UserLoginFeature
:members:


Contrib for ``balderhub-crud``
==============================

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ balderhub-gui
balderhub-webdriver
balderhub-selenium
balderhub-url
balderhub-crud
balderhub-crud
balderhub-auth~=0.0.1b1
7 changes: 6 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ project_urls =
packages =
balderhub.html
balderhub.html.contrib
balderhub.html.contrib.auth
balderhub.html.contrib.auth.pages
balderhub.html.contrib.auth.setup_features
balderhub.html.contrib.crud
balderhub.html.contrib.crud.utils
balderhub.html.contrib.crud.utils.field_callbacks
Expand All @@ -55,7 +58,9 @@ setup_requires =
zip_safe = no

[options.extras_require]
auth =
balderhub-auth>=0.0.1b1
crud =
balderhub-crud>=0.0.1b8
all =
balderhub-html[crud]
balderhub-html[auth,crud]
Empty file.
5 changes: 5 additions & 0 deletions src/balderhub/html/contrib/auth/pages/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .login_page import LoginPage

__all__ = [
'LoginPage',
]
51 changes: 51 additions & 0 deletions src/balderhub/html/contrib/auth/pages/login_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from typing import Union, List

import balderhub.html.lib.scenario_features

import balderhub.html.lib.utils.components as html
from balderhub.url.lib.utils import Url


class LoginPage(balderhub.html.lib.scenario_features.HtmlPage):
"""
HTML Page for normal login pages as abstract base class - all abstract methods/properties needs to be defined in
subclass
"""

@property
def url(self) -> Url:
"""
:return: non-schema url the login page is located at
"""
raise NotImplementedError

@property
def applicable_on_url_schema(self) -> Union[Url, List[Url]]:
return self.url

def open(self) -> None:
"""
This method opens the login page.
"""
self.driver.navigate_to(self.url)

@property
def input_username(self) -> html.inputs.HtmlTextInput:
"""
:return: Html input field where the username needs to be filled
"""
raise NotImplementedError

@property
def input_password(self) -> html.inputs.HtmlPasswordInput:
"""
:return: Html input field where the password needs to be filled
"""
raise NotImplementedError

@property
def btn_login(self) -> html.HtmlButtonElement:
"""
:return: HTML button to submit the login form
"""
raise NotImplementedError
5 changes: 5 additions & 0 deletions src/balderhub/html/contrib/auth/setup_features/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .user_login_feature import UserLoginFeature

__all__ = [
"UserLoginFeature"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import balderhub.auth.lib.scenario_features.client.user_login_feature

from ..pages.login_page import LoginPage


class UserLoginFeature(balderhub.auth.lib.scenario_features.client.user_login_feature.UserLoginFeature):
"""
Implementation of the user login feature for using the :class:`balderhub.contrib.html.pages.LoginPage` HTML pages
"""

page = LoginPage()

def insert_username(self, username: str) -> None:
self.page.input_username.wait_to_be_clickable_for(1).type_text(username, clean_before=True)

def insert_password(self, password: str) -> None:
self.page.input_password.wait_to_be_clickable_for(1).type_text(password, clean_before=True)

def submit_login(self) -> None:
self.page.btn_login.wait_to_be_clickable_for(1).click()

def is_already_logged_in(self):
# TODO improve
self.page.open()
return not self.page.is_applicable()
Loading