Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 2697a70

Browse files
fixed tests
1 parent 248e994 commit 2697a70

File tree

2 files changed

+49
-21
lines changed

2 files changed

+49
-21
lines changed

tests/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,20 @@ def dash_dcc(request, dash_thread_server, tmpdir):
3333
pause=request.config.getoption("pause"),
3434
) as dc:
3535
yield dc
36+
37+
38+
@pytest.fixture
39+
def dash_dcc_headed(request, dash_thread_server, tmpdir):
40+
with DashCoreComponentsComposite(
41+
dash_thread_server,
42+
browser=request.config.getoption("webdriver"),
43+
remote=request.config.getoption("remote"),
44+
remote_url=request.config.getoption("remote_url"),
45+
headless=False,
46+
options=request.config.hook.pytest_setup_options(),
47+
download_path=tmpdir.mkdir("download").strpath,
48+
percy_assets_root=request.config.getoption("percy_assets"),
49+
percy_finalize=request.config.getoption("nopercyfinalize"),
50+
pause=request.config.getoption("pause"),
51+
) as dc:
52+
yield dc
Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,59 @@
11
import dash
22
import dash_core_components as dcc
33
import dash_html_components as html
4+
import dash.testing.wait as wait
5+
import time
6+
47

58
from selenium.webdriver.common.action_chains import ActionChains
69
from selenium.webdriver.common.keys import Keys
710

811

9-
def test_clp001_clipboard_text(dash_dcc):
12+
def test_clp001_clipboard_text(dash_dcc_headed):
1013
copy_text = "Hello, Dash!"
1114
app = dash.Dash(__name__, prevent_initial_callbacks=True)
1215
app.layout = html.Div(
1316
[
14-
html.Div(copy_text, id="copy"),
15-
dcc.Clipboard(id="copy_icon", target_id="copy"),
16-
dcc.Textarea(id="paste"),
17+
html.Div(copy_text, id="copy1"),
18+
dcc.Clipboard(id="copy_icon1", target_id="copy1"),
19+
dcc.Textarea(id="paste1"),
1720
]
1821
)
19-
dash_dcc.start_server(app)
22+
dash_dcc_headed.start_server(app)
23+
dash_dcc_headed.driver.execute_script("navigator.clipboard.writeText('')")
2024

21-
dash_dcc.find_element("#copy_icon").click()
22-
dash_dcc.find_element("#paste").click()
23-
ActionChains(dash_dcc.driver).key_down(Keys.CONTROL).send_keys("v").key_up(
25+
dash_dcc_headed.find_element("#copy_icon1").click()
26+
time.sleep(2)
27+
dash_dcc_headed.find_element("#paste1").click()
28+
ActionChains(dash_dcc_headed.driver).key_down(Keys.CONTROL).send_keys("v").key_up(
2429
Keys.CONTROL
2530
).perform()
2631

27-
elem = dash_dcc.find_element("#paste")
28-
val = elem.get_attribute("value")
29-
assert val == copy_text
32+
wait.until(
33+
lambda: dash_dcc_headed.find_element("#paste1").get_attribute("value")
34+
== copy_text,
35+
timeout=3,
36+
)
3037

3138

32-
def test_clp002_clipboard_text(dash_dcc):
33-
copy_text = "Copy"
39+
def test_clp002_clipboard_text(dash_dcc_headed):
40+
copy_text = "Copy this text to the clipboard"
3441
app = dash.Dash(__name__, prevent_initial_callbacks=True)
3542
app.layout = html.Div(
36-
[dcc.Clipboard(id="copy_icon", text=copy_text), dcc.Textarea(id="paste")]
43+
[dcc.Clipboard(id="copy_icon2", text=copy_text), dcc.Textarea(id="paste2")]
3744
)
38-
dash_dcc.start_server(app)
45+
dash_dcc_headed.start_server(app)
46+
dash_dcc_headed.driver.execute_script("navigator.clipboard.writeText('')")
3947

40-
dash_dcc.find_element("#copy_icon").click()
41-
dash_dcc.find_element("#paste").click()
42-
ActionChains(dash_dcc.driver).key_down(Keys.CONTROL).send_keys("v").key_up(
48+
dash_dcc_headed.find_element("#copy_icon2").click()
49+
time.sleep(2)
50+
dash_dcc_headed.find_element("#paste2").click()
51+
ActionChains(dash_dcc_headed.driver).key_down(Keys.CONTROL).send_keys("v").key_up(
4352
Keys.CONTROL
4453
).perform()
4554

46-
elem = dash_dcc.find_element("#paste")
47-
val = elem.get_attribute("value")
48-
assert val == copy_text
55+
wait.until(
56+
lambda: dash_dcc_headed.find_element("#paste2").get_attribute("value")
57+
== copy_text,
58+
timeout=3,
59+
)

0 commit comments

Comments
 (0)