diff --git a/docs/about/release-notes.rst b/docs/about/release-notes.rst index 4886829..1f984d4 100644 --- a/docs/about/release-notes.rst +++ b/docs/about/release-notes.rst @@ -13,6 +13,11 @@ To upgrade Sdklib to the latest version, use pip: Sdklib 1.9.x series =================== +Sdklib 1.9.1 +------------ + +- Add getparent method to LxmlElem class. + Sdklib 1.9.0 ------------ diff --git a/sdklib/__init__.py b/sdklib/__init__.py index e5102d3..35424e8 100644 --- a/sdklib/__init__.py +++ b/sdklib/__init__.py @@ -1 +1 @@ -__version__ = '1.9.0' +__version__ = '1.9.1' diff --git a/sdklib/html/elem.py b/sdklib/html/elem.py index 2e1d62f..f8fc283 100644 --- a/sdklib/html/elem.py +++ b/sdklib/html/elem.py @@ -9,6 +9,15 @@ class ElemLxml(HTMLLxmlMixin, AbstractBaseHTMLElem): def __init__(self, lxml_elem): self.html_obj = lxml_elem + def getparent(self, height=1): + parent = self.html_obj.getparent() + for _ in range(0, height): + if parent is None: + return + parent = parent.getparent() + if parent is not None: + return ElemLxml(parent) + class Elem5lib(HTML5libMixin, AbstractBaseHTMLElem): """ diff --git a/tests/resources/test.html b/tests/resources/test.html index 488e3ff..0723ba7 100644 --- a/tests/resources/test.html +++ b/tests/resources/test.html @@ -995,7 +995,7 @@