Compare commits

..

5 Commits

Author SHA1 Message Date
dgtlmoon
24baf44faa Merge branch 'master' into browserstep-refactor 2023-05-12 15:11:09 +02:00
dgtlmoon
d0e5c457e0 tweak timeouts and proxy 2023-05-12 14:48:46 +02:00
dgtlmoon
266c6ba1c0 BrowserSteps - refactor 2023-05-12 14:39:51 +02:00
dgtlmoon
a46bbc8300 BrowserSteps - Refactored to re-use playwright context which should solve some errors 2023-05-12 14:18:45 +02:00
dgtlmoon
d865ea0103 BrowserSteps - Use playwright 'force' click for elements that arent clickable (div etc) 2023-05-12 10:36:33 +02:00
6 changed files with 11 additions and 32 deletions

View File

@@ -104,17 +104,14 @@ def construct_blueprint(datastore: ChangeDetectionStore):
# A new session was requested, return sessionID
import uuid
global browsersteps_sessions
browsersteps_session_id = str(uuid.uuid4())
watch_uuid = request.args.get('uuid')
if not watch_uuid:
return make_response('No Watch UUID specified', 500)
watch_uuid = request.args.get('uuid')
global browsersteps_sessions
print("Starting connection with playwright")
logging.debug("browser_steps.py connecting")
browsersteps_sessions[browsersteps_session_id] = start_browsersteps_session(watch_uuid)
browsersteps_sessions[browsersteps_session_id] = start_browsersteps_session()
print("Starting connection with playwright - done")
return {'browsersteps_session_id': browsersteps_session_id}

View File

@@ -133,7 +133,7 @@ class steppable_browser_interface():
self.page.wait_for_timeout(1000)
def action_wait_for_seconds(self, selector, value):
self.page.wait_for_timeout(float(value.strip()) * 1000)
self.page.wait_for_timeout(int(value) * 1000)
def action_wait_for_text(self, selector, value):
import json

View File

@@ -54,7 +54,6 @@ class perform_site_check(difference_detection_processor):
changed_detected = False
screenshot = False # as bytes
stripped_text_from_html = ""
source_filter = None # A machine filter that can be applied to source: (url|filter)
# DeepCopy so we can be sure we don't accidently change anything by reference
watch = deepcopy(self.datastore.data['watching'].get(uuid))
@@ -250,11 +249,6 @@ class perform_site_check(difference_detection_processor):
for filter_rule in include_filters_rule:
# For HTML/XML we offer xpath as an option, just start a regular xPath "/.."
if '|' in filter_rule:
filter_rule, source_filter = filter_rule.split('|')
else:
source_filter = None
if filter_rule[0] == '/' or filter_rule.startswith('xpath:'):
html_content += html_tools.xpath_filter(xpath_filter=filter_rule.replace('xpath:', ''),
html_content=fetcher.content,
@@ -264,10 +258,6 @@ class perform_site_check(difference_detection_processor):
html_content += html_tools.include_filters(include_filters=filter_rule,
html_content=fetcher.content,
append_pretty_line_formatting=not is_source)
if source_filter == 'pretty':
from bs4 import BeautifulSoup
html_content = BeautifulSoup(html_content, 'html.parser').prettify()
if not html_content.strip():
raise FilterNotFoundInResponse(include_filters_rule)

View File

@@ -162,9 +162,7 @@ $(document).ready(function () {
) {
// There could be many elements here, record them all and then we'll find out which is the most 'useful'
// (input, textarea, button, A etc)
if (item.width < xpath_data['browser_width']) {
possible_elements.push(item);
}
possible_elements.push(item);
}
});
@@ -422,6 +420,7 @@ $(document).ready(function () {
apply_buttons_disabled = false;
$("#browsersteps-img").css('opacity', 1);
$('ul#browser_steps li .control .apply').css('opacity', 1);
browserless_seconds_remaining = data.browser_time_remaining;
$("#loading-status-text").hide();
set_first_gotosite_disabled();
}).fail(function (data) {

View File

@@ -61,12 +61,7 @@ $(document).ready(function () {
function bootstrap_visualselector() {
if (1) {
// bootstrap it, this will trigger everything else
$("img#selector-background").on("error", function () {
$('.fetching-update-notice').html("<strong>Ooops!</strong> The VisualSelector tool needs atleast one fetched page, please unpause the watch and/or wait for the watch to complete fetching and then reload this page.");
$('.fetching-update-notice').css('color','#bb0000');
$('#selector-current-xpath').hide();
$('#clear-selector').hide();
}).bind('load', function () {
$("img#selector-background").bind('load', function () {
console.log("Loaded background...");
c = document.getElementById("selector-canvas");
// greyed out fill context
@@ -84,11 +79,10 @@ $(document).ready(function () {
}).attr("src", screenshot_url);
}
// Tell visualSelector that the image should update
var s = $("img#selector-background").attr('src') + "?" + new Date().getTime();
$("img#selector-background").attr('src', s)
var s = $("img#selector-background").attr('src')+"?"+ new Date().getTime();
$("img#selector-background").attr('src',s)
}
// This is fired once the img src is loaded in bootstrap_visualselector()
function fetch_data() {
// Image is ready
$('.fetching-update-notice').html("Fetching element data..");
@@ -105,8 +99,7 @@ $(document).ready(function () {
reflow_selector();
$('.fetching-update-notice').fadeOut();
});
}
};
function set_scale() {

View File

@@ -106,7 +106,7 @@
</div>
{% if hosted_sticky %}
<div class="sticky-tab" id="hosted-sticky">
<a href="https://changedetection.io/?ref={{guid}}">Let us host your instance!</a>
<a href="https://lemonade.changedetection.io/start?ref={{guid}}">Let us host your instance!</a>
</div>
{% endif %}
{% if left_sticky %}