Rename check responsive_layout to load_in_browser

This commit is contained in:
Marian Steinbach 2018-10-01 11:06:16 +02:00
parent 876e91bde6
commit 456272a2af
5 changed files with 22 additions and 21 deletions

View file

@ -13,7 +13,7 @@ from checks import generator
from checks import html_head
from checks import http_and_https
from checks import page_content
from checks import responsive_layout
from checks import load_in_browser
from checks import url_reachability
from checks import url_canonicalization
@ -39,7 +39,7 @@ def perform_checks(input_url):
('charset', charset),
('html_head', html_head),
('generator', generator),
('responsive_layout', responsive_layout),
('load_in_browser', load_in_browser),
]
results = {}

View file

@ -1,11 +1,10 @@
"""
Check for responsive layout.
Collects information by loading pages in a browser.
This loads any input URL once in Chrome and checks whether the document width
adapts well to viewports as little as 360 pixels wide.
Information includes:
In addition, the check captures javascript errors and warnings from
missing resources
- whether the document width adapts well to viewports as little as 360 pixels wide
- whether javascript errors or errors from missing resources occur
"""
import logging
@ -33,7 +32,6 @@ class Checker(AbstractChecker):
def __init__(self, config, previous_results=None):
super().__init__(config, previous_results)
def run(self):
# Our selenium user agent using Chrome headless as an engine
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
@ -43,8 +41,11 @@ class Checker(AbstractChecker):
self.driver = webdriver.Chrome(chrome_options=chrome_options)
self.driver.set_page_load_timeout(self.page_load_timeout)
def run(self):
results = {}
for url in self.config.urls:
# responsive check
try:
sizes = self.check_responsiveness(url)
results[url] = {
@ -58,7 +59,7 @@ class Checker(AbstractChecker):
except tenacity.RetryError as re:
logging.warn("RetryError when checking responsiveness for %s: %s" % (url, re))
pass
self.driver.quit()
return results

View file

@ -8,7 +8,7 @@ class Rater(AbstractRater):
rating_type = 'boolean'
default_value = False
depends_on_checks = ['responsive_layout']
depends_on_checks = ['load_in_browser']
max_score = 1
def __init__(self, check_results):
@ -20,13 +20,13 @@ class Rater(AbstractRater):
found_pageloads = 0
found_errors = 0
for url in self.check_results['responsive_layout']:
if self.check_results['responsive_layout'][url]['logs'] == []:
for url in self.check_results['load_in_browser']:
if self.check_results['load_in_browser'][url]['logs'] == []:
found_pageloads += 1
continue
# scan log entries for script errors
for entry in self.check_results['responsive_layout'][url]['logs']:
for entry in self.check_results['load_in_browser'][url]['logs']:
if entry['source'] != 'network':
continue
if entry['level'] != 'SEVERE':

View file

@ -8,7 +8,7 @@ class Rater(AbstractRater):
rating_type = 'boolean'
default_value = False
depends_on_checks = ['responsive_layout']
depends_on_checks = ['load_in_browser']
max_score = 1
def __init__(self, check_results):
@ -20,13 +20,13 @@ class Rater(AbstractRater):
found_pageloads = 0
found_errors = 0
for url in self.check_results['responsive_layout']:
if self.check_results['responsive_layout'][url]['logs'] == []:
for url in self.check_results['load_in_browser']:
if self.check_results['load_in_browser'][url]['logs'] == []:
found_pageloads += 1
continue
# scan log entries for script errors
for entry in self.check_results['responsive_layout'][url]['logs']:
for entry in self.check_results['load_in_browser'][url]['logs']:
if entry['source'] == 'javascript':
found_errors += 1

View file

@ -9,7 +9,7 @@ class Rater(AbstractRater):
rating_type = 'boolean'
default_value = False
depends_on_checks = ['responsive_layout']
depends_on_checks = ['load_in_browser']
max_score = 1
def __init__(self, check_results):
@ -19,9 +19,9 @@ class Rater(AbstractRater):
value = self.default_value
score = 0
for url in self.check_results['responsive_layout']:
if (self.check_results['responsive_layout'][url]['min_document_width'] <=
self.check_results['responsive_layout'][url]['sizes'][0]['viewport_width']):
for url in self.check_results['load_in_browser']:
if (self.check_results['load_in_browser'][url]['min_document_width'] <=
self.check_results['load_in_browser'][url]['sizes'][0]['viewport_width']):
value = True
score = self.max_score
# we use the first URL found here