-
-
Notifications
You must be signed in to change notification settings - Fork 143
Issue479 - Fix Vertical Slider regression #481
Changes from all commits
6e3ba9a
c8065a9
f261f57
1c9dc1b
1faedfc
29abf7b
a71633b
fcc23ca
ae058b8
51ac3e6
b79935b
bf63acd
ae84539
8341d22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
|
|
||
| from selenium import webdriver | ||
| from selenium.webdriver.chrome.options import Options | ||
| from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | ||
|
|
||
|
|
||
| class IntegrationTests(unittest.TestCase): | ||
|
|
@@ -20,11 +21,13 @@ def setUpClass(cls): | |
| super(IntegrationTests, cls).setUpClass() | ||
|
|
||
| options = Options() | ||
| capabilities = DesiredCapabilities.CHROME | ||
| capabilities['loggingPrefs'] = {'browser': 'SEVERE'} | ||
|
|
||
| if 'DASH_TEST_CHROMEPATH' in os.environ: | ||
| options.binary_location = os.environ['DASH_TEST_CHROMEPATH'] | ||
|
|
||
| cls.driver = webdriver.Chrome(chrome_options=options) | ||
| cls.driver = webdriver.Chrome(options=options, desired_capabilities=capabilities) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Settings to get browser errors |
||
| loader = percy.ResourceLoader( | ||
| webdriver=cls.driver, | ||
| base_url='/assets', | ||
|
|
@@ -47,7 +50,8 @@ def tearDown(self): | |
| requests.get('http://localhost:8050/stop') | ||
| else: | ||
| self.server_process.terminate() | ||
| self.driver.back() | ||
|
|
||
| self.clear_log() | ||
| time.sleep(1) | ||
|
|
||
| def startServer(self, app): | ||
|
|
@@ -103,28 +107,15 @@ def _stop_server_windows(): | |
| # Visit the dash page | ||
| self.driver.get('http://localhost:8050') | ||
|
|
||
| # Inject an error and warning logger | ||
| logger = ''' | ||
| window.tests = {}; | ||
| window.tests.console = {error: [], warn: [], log: []}; | ||
|
|
||
| var _log = console.log; | ||
| var _warn = console.warn; | ||
| var _error = console.error; | ||
|
|
||
| console.log = function() { | ||
| window.tests.console.log.push({method: 'log', arguments: arguments}); | ||
| return _log.apply(console, arguments); | ||
| }; | ||
|
|
||
| console.warn = function() { | ||
| window.tests.console.warn.push({method: 'warn', arguments: arguments}); | ||
| return _warn.apply(console, arguments); | ||
| }; | ||
|
|
||
| console.error = function() { | ||
| window.tests.console.error.push({method: 'error', arguments: arguments}); | ||
| return _error.apply(console, arguments); | ||
| }; | ||
| ''' | ||
| self.driver.execute_script(logger) | ||
| def clear_log(self): | ||
| entries = self.driver.get_log("browser") | ||
|
|
||
| if entries: | ||
| self.last_timestamp = entries[-1]["timestamp"] | ||
|
|
||
| def get_log(self): | ||
| entries = self.driver.get_log("browser") | ||
|
|
||
| return [entry for entry in entries if entry["timestamp"] > self.last_timestamp] | ||
|
|
||
| last_timestamp = 0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,6 +217,34 @@ def test_upload_gallery(self): | |
|
|
||
| self.snapshot('test_upload_gallery') | ||
|
|
||
| def test_vertical_slider(self): | ||
| app = dash.Dash(__name__) | ||
|
|
||
| app.layout = html.Div([ | ||
| html.Label('Vertical Slider'), | ||
| dcc.Slider( | ||
| id='vertical-slider', | ||
| min=0, | ||
| max=9, | ||
| marks={i: 'Label {}'.format(i) if i == 1 else str(i) | ||
| for i in range(1, 6)}, | ||
| value=5, | ||
| vertical=True, | ||
| ), | ||
| ], style={'height': '500px'}) | ||
| self.startServer(app) | ||
|
|
||
| self.wait_for_element_by_css_selector('#vertical-slider') | ||
| self.snapshot('vertical slider') | ||
|
|
||
| v_slider = self.driver.find_element_by_css_selector( | ||
| '#vertical-slider div[role="slider"]' | ||
| ) | ||
| v_slider.click() | ||
|
|
||
| for entry in self.get_log(): | ||
| raise Exception('browser error logged during test', entry) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there's a message here, something went wrong. Not doing this for all tests as lots of tests have issues at the moment.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if this test shouldn't be in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the gallery snapshot approach is a bad idea in general. When I see a diff I want that diff to be isolated and linked to as little dependencies as possible. If the vertical slider breaks, it's obvious. And no wondering if there's multiple issues in the single diff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed - so many times I've had to look at a diff where something was added in the middle of a long page... and percy has no idea that it's all the same content just shifted down, so I have to try and do that diffing in my head. Much better to break these up into single-purpose images, and not worry about making a huge total number of images. |
||
|
|
||
| def test_gallery(self): | ||
| app = dash.Dash(__name__) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried in vain to find docs for this, did you? If this config does what's needed here that's fine for this PR, I'm just curious if we might like other settings in other cases, to get messages that don't quite rise to the level of SEVERE
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities#loggingpreferences-json-object
Available values for most loggers are "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST", "ALL".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm yeah, I saw that one, but it also says
Which I was hoping existed somewhere and would tell us something about what kind of messages are included in each level... oh well, trial and error I guess.