Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.7 #114

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

0.2.7 #114

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
234 changes: 140 additions & 94 deletions Pipfile.lock

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion docs/source/component.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ mapping and operating against arbitrary components.
>> 'group': [],
>> {

Root Selectors
==============

When creating components where each attributed Element or Elements instance will be pulling from the same base selector, you can leverage a component level root selector to help simplify development.
Component root selectors are denoted by a static attribute, `_`.

.. code-block:: python

class MyModal(Component):

# root selector specification
_ = 'div.modal'

@component_element
def title(self):
# this selector will be processed as 'div.modal h1.modal-title'
return 'h1.modal-title'

Element (wrapper)
=================

Expand Down Expand Up @@ -169,7 +187,7 @@ If you require the traditional clicking behavior, simplify fetch a selenium WebE

component.button.get().click()

Additionally, for elements that do not listen on the click event but rather mouseup or mousedown, you may refer to the api methods `mouseup` and `mousedown` (chainable):
Additionally, for elements that do not listen on the click event but rather mouseup or mousedown, you may refer to the api methods *mouseup* and *mousedown* (chainable):

.. code-block:: python

Expand All @@ -194,6 +212,18 @@ You may also leverage the *select* api method for option child elements of selec

component.language_options.python.select()

Hovering Over an Element
------------------------

The element wrapper allows you to hover over an element using the *mouseover* api method (chainable). You may also leave an element by leveraging *mouseup*.

.. code-block:: python

component.button\
.mouseover()\
.mouseleave()


Scrolling To an Element
-----------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
# built documents.
#
# The short X.Y version.
version = u'0.2.6'
version = u'0.2.7'
# The full version, including alpha/beta/rc tags.
release = u'0.2.6'
release = u'0.2.7'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
8 changes: 5 additions & 3 deletions pyscc/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def _log(self, level, msg, args, exc_info=None, extra=None):
super(ControllerLogger, self)._log(level, msg, args, exc_info, extra)


# pylint: disable=useless-object-inheritance
class Controller(object):

_FILTER_SELENIUM_LOGS_ = False
Expand Down Expand Up @@ -247,7 +248,7 @@ def search():
self.browser.switch_to_window(handle)
if strict and title == self.title:
return True
elif not strict and title in self.title:
if not strict and title in self.title:
return True
return False

Expand Down Expand Up @@ -280,7 +281,7 @@ def search():
self.browser.switch_to_window(handle)
if strict and location == self.location:
return True
elif not strict and location in self.location:
if not strict and location in self.location:
return True
return False

Expand All @@ -296,7 +297,7 @@ def search():
return result

@classmethod
def wait(cls, timeout=1, condition=None, reverse=False, throw_error=False):
def wait(cls, timeout=1, condition=None, reverse=False, throw_error=False): # pylint: disable=no-else-return
"""
Assisted delays between browser and main thread.

Expand All @@ -308,6 +309,7 @@ def wait(cls, timeout=1, condition=None, reverse=False, throw_error=False):
:type throw_error: bool
:return: bool
"""
# pylint: disable=no-else-return
if callable(condition):
if not isinstance(timeout, int) or timeout < 1:
raise ValueError('Timeout must be an integer or float greater than or equal to 1')
Expand Down
28 changes: 28 additions & 0 deletions pyscc/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# specific language governing permissions and limitations
# under the License.

# pylint: disable=too-many-lines

from string import Template
from types import MethodType
from selenium.common.exceptions import NoSuchElementException, ElementNotVisibleException, \
Expand Down Expand Up @@ -244,6 +246,32 @@ def mousedown(self):
return self
return None

def mouseover(self):
"""
Dispatches a mouseover event on the given element.

:return: Element, None
"""
found = self.get()
if found:
self.controller.js.scroll_into_view(found)
self.controller.js.trigger_event(found, 'mouseover', 'MouseEvent')
return found
return None

def mouseleave(self):
"""
Dispatches a mouseleave event on the given element.

:return: Element, None
"""
found = self.get()
if found:
self.controller.js.scroll_into_view(found)
self.controller.js.trigger_event(found, 'mouseleave', 'MouseEvent')
return found
return None

def select(self):
"""
Selects an option child element of a select element naturally.
Expand Down
3 changes: 2 additions & 1 deletion pyscc/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from six import iteritems


class Resource(object): # pylint: disable=too-few-public-methods
# pylint: disable=too-few-public-methods,useless-object-inheritance
class Resource(object):
"""
Base object for shenanigans.
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
setup(
name='pyscc',
description='py-component-controller is an opinionated framework for structuring selenium test suites. This project depends on the pyselenium-js project.',
version='0.2.6',
version='0.2.7',
url='https://neetjn.github.io/py-component-controller/',
author='John Nolette',
author_email='[email protected]',
Expand Down