Skip to content

Commit

Permalink
Merge pull request #29 from scivisum/task/RD-37645_remove_usages_of_lxml
Browse files Browse the repository at this point in the history
[RD-37645] Removed validation of xpaths, and dep lxml
  • Loading branch information
erustusagutu committed Jan 16, 2020
2 parents cde45d5 + 447a2f1 commit 9c2a7c8
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 26 deletions.
12 changes: 1 addition & 11 deletions browserdebuggertools/chrome/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import logging
from base64 import b64decode, b64encode

from lxml.etree import XPath, XPathSyntaxError

from browserdebuggertools.exceptions import InvalidXPathError, ResourceNotFoundError
from browserdebuggertools.exceptions import ResourceNotFoundError
from browserdebuggertools.sockethandler import SocketHandler


Expand Down Expand Up @@ -196,17 +194,9 @@ def get_iframe_source_content(self, xpath):
:param xpath: following the spec 3.1 https://www.w3.org/TR/xpath-31/
:return: HTML markup
:raises XPathSyntaxError: The given xpath is invalid
:raises IFrameNotFoundError: A matching iframe document could not be found
:raises UnknownError: The socket handler received a message with an unknown error code
"""

try:
XPath(xpath) # Validates the xpath

except XPathSyntaxError:
raise InvalidXPathError("{0} is not a valid xpath".format(xpath))

return self._dom_manager.get_iframe_html(xpath)

def get_page_source(self):
Expand Down
4 changes: 0 additions & 4 deletions browserdebuggertools/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,5 @@ class MaxRetriesException(DevToolsException):
pass


class InvalidXPathError(DevToolsException):
pass


class UnknownError(ProtocolError):
pass
1 change: 0 additions & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ requests
mock
typing
jinja2
lxml
websocket-client==0.56
cherrypy==17.4.2
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
"requests",
"websocket-client",
"typing",
"lxml"
]


PACKAGES = find_packages(include="browserdebuggertools*")

setup(
name="browserdebuggertools",
version="5.2.0",
version="5.3.0",
packages=PACKAGES,
install_requires=requires,
license="GNU General Public License v3",
Expand Down
9 changes: 1 addition & 8 deletions tests/e2etests/chrome/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from browserdebuggertools.exceptions import (
DevToolsException, DevToolsTimeoutException, JavascriptDialogNotFoundError,
InvalidXPathError, ResourceNotFoundError
ResourceNotFoundError
)
from browserdebuggertools.models import JavascriptDialog
from tests.e2etests.testsite.start import Server as TestSiteServer, env
Expand Down Expand Up @@ -584,13 +584,6 @@ def test_node_found_but_its_not_an_iframe(self):
with self.assertRaises(ResourceNotFoundError):
self.devtools_client.get_iframe_source_content("//div")

def test_invalid_xpath(self):

assert isinstance(self, (ChromeInterfaceTest, TestCase))

with self.assertRaises(InvalidXPathError):
self.devtools_client.get_iframe_source_content("@@")


class Test_ChromeInterface_test_get_frame_html_headed(
HeadedChromeInterfaceTest, Test_ChromeInterface_test_get_iframe_source_content, TestCase
Expand Down

0 comments on commit 9c2a7c8

Please sign in to comment.