|
| 1 | +import pytest |
1 | 2 | from pytest_dash.utils import (
|
2 | 3 | import_app,
|
3 | 4 | wait_for_text_to_equal,
|
4 | 5 | wait_for_element_by_css_selector
|
5 | 6 | )
|
| 7 | +from selenium.webdriver.support.ui import Select |
6 | 8 |
|
7 | 9 |
|
8 |
| -# Basic test for the component rendering. |
9 |
| -def test_render_component(dash_threaded, selenium): |
| 10 | +@pytest.fixture |
| 11 | +def usage_app(dash_threaded): |
10 | 12 | # Start a dash app contained in `usage.py`
|
11 | 13 | # dash_threaded is a fixture by pytest-dash
|
12 | 14 | # It will load a py file containing a Dash instance named `app`
|
13 | 15 | # and start it in a thread.
|
14 | 16 | app = import_app('usage')
|
15 | 17 | dash_threaded(app)
|
| 18 | + return app |
16 | 19 |
|
17 |
| - # Get the generated component input with selenium |
18 |
| - # The html input will be a children of the #input dash component |
19 |
| - my_component = wait_for_element_by_css_selector(selenium, '#input > input') |
| 20 | +def test_dashboard_test_textarea(usage_app, selenium): |
| 21 | + dashboard_test_textarea = wait_for_element_by_css_selector(selenium, '#dashboard-test-textarea') |
| 22 | + assert 'Hello, world!' == dashboard_test_textarea.get_attribute('value') |
| 23 | + dashboard_test_textarea.send_keys('TEST') |
| 24 | + wait_for_text_to_equal(selenium, '#dashboard-test-output', |
| 25 | + 'You have entered "Hello, world!TEST". You selected None in the aside dropdown and the aside slider sits at 3.') |
20 | 26 |
|
21 |
| - assert 'my-value' == my_component.get_attribute('value') |
22 |
| - |
23 |
| - # Clear the input |
24 |
| - my_component.clear() |
25 |
| - |
26 |
| - # Send keys to the custom input. |
27 |
| - my_component.send_keys('Hello dash') |
28 |
| - |
29 |
| - # Wait for the text to equal, if after the timeout (default 10 seconds) |
30 |
| - # the text is not equal it will fail the test. |
31 |
| - wait_for_text_to_equal(selenium, '#output', 'You have entered Hello dash') |
0 commit comments