|
|
|
@ -24,8 +24,8 @@ class Fetcher():
|
|
|
|
|
content = None
|
|
|
|
|
headers = None
|
|
|
|
|
|
|
|
|
|
fetcher_description ="No description"
|
|
|
|
|
xpath_element_js="""
|
|
|
|
|
fetcher_description = "No description"
|
|
|
|
|
xpath_element_js = """
|
|
|
|
|
// Include the getXpath script directly, easier than fetching
|
|
|
|
|
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).getXPath=n()}(this,function(){return function(e){var n=e;if(n&&n.id)return'//*[@id="'+n.id+'"]';for(var o=[];n&&Node.ELEMENT_NODE===n.nodeType;){for(var i=0,r=!1,d=n.previousSibling;d;)d.nodeType!==Node.DOCUMENT_TYPE_NODE&&d.nodeName===n.nodeName&&i++,d=d.previousSibling;for(d=n.nextSibling;d;){if(d.nodeName===n.nodeName){r=!0;break}d=d.nextSibling}o.push((n.prefix?n.prefix+":":"")+n.localName+(i||r?"["+(i+1)+"]":"")),n=n.parentNode}return o.length?"/"+o.reverse().join("/"):""}});
|
|
|
|
|
//# sourceMappingURL=index.umd.js.map
|
|
|
|
@ -121,7 +121,7 @@ class Fetcher():
|
|
|
|
|
|
|
|
|
|
return size_pos;
|
|
|
|
|
"""
|
|
|
|
|
xpath_data=None
|
|
|
|
|
xpath_data = None
|
|
|
|
|
|
|
|
|
|
# Will be needed in the future by the VisualSelector, always get this where possible.
|
|
|
|
|
screenshot = False
|
|
|
|
@ -155,6 +155,7 @@ class Fetcher():
|
|
|
|
|
def is_ready(self):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Maybe for the future, each fetcher provides its own diff output, could be used for text, image
|
|
|
|
|
# the current one would return javascript output (as we use JS to generate the diff)
|
|
|
|
|
#
|
|
|
|
@ -180,10 +181,10 @@ class base_html_playwright(Fetcher):
|
|
|
|
|
if os.getenv("PLAYWRIGHT_DRIVER_URL"):
|
|
|
|
|
fetcher_description += " via '{}'".format(os.getenv("PLAYWRIGHT_DRIVER_URL"))
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
# from playwright.sync_api import sync_playwright
|
|
|
|
|
# except ModuleNotFoundError:
|
|
|
|
|
# fetcher_enabled = False
|
|
|
|
|
# try:
|
|
|
|
|
# from playwright.sync_api import sync_playwright
|
|
|
|
|
# except ModuleNotFoundError:
|
|
|
|
|
# fetcher_enabled = False
|
|
|
|
|
|
|
|
|
|
browser_type = ''
|
|
|
|
|
command_executor = ''
|
|
|
|
@ -255,7 +256,7 @@ class base_html_playwright(Fetcher):
|
|
|
|
|
else:
|
|
|
|
|
page.evaluate("var css_filter=''")
|
|
|
|
|
|
|
|
|
|
self.xpath_data = page.evaluate("async () => {"+ self.xpath_element_js+ "}")
|
|
|
|
|
self.xpath_data = page.evaluate("async () => {" + self.xpath_element_js + "}")
|
|
|
|
|
# Some bug where it gives the wrong screenshot size, but making a request with the clip set first seems to solve it
|
|
|
|
|
# JPEG is better here because the screenshots can be very very large
|
|
|
|
|
page.screenshot(type='jpeg', clip={'x': 1.0, 'y': 1.0, 'width': 1280, 'height': 1024})
|
|
|
|
@ -324,7 +325,7 @@ class base_html_webdriver(Fetcher):
|
|
|
|
|
|
|
|
|
|
self.driver.set_window_size(1280, 1024)
|
|
|
|
|
self.driver.implicitly_wait(int(os.getenv("WEBDRIVER_DELAY_BEFORE_CONTENT_READY", 5)))
|
|
|
|
|
self.xpath_data = self.driver.execute_script("var css_filter='{}';".format(current_css_filter)+self.xpath_element_js)
|
|
|
|
|
self.xpath_data = self.driver.execute_script("var css_filter='{}';".format(current_css_filter) + self.xpath_element_js)
|
|
|
|
|
self.screenshot = self.driver.get_screenshot_as_png()
|
|
|
|
|
|
|
|
|
|
# @todo - how to check this? is it possible?
|
|
|
|
@ -350,8 +351,6 @@ class base_html_webdriver(Fetcher):
|
|
|
|
|
self.quit()
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def quit(self):
|
|
|
|
|
if self.driver:
|
|
|
|
|
try:
|
|
|
|
|