-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathtest_multiple_outputs.py
109 lines (103 loc) · 3.13 KB
/
test_multiple_outputs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from selenium.webdriver.support.select import Select
app = """
library(dash)
library(plotly)
app <- Dash$new()
app$layout(
html$div(list(
html$div(list(
html$h1('Multi output example'),
dccDropdown(id='data-dropdown',
options = list(
list(label = 'Movies',
value = 'movies'),
list(label = 'Series',
value = 'series')
),
value = 'movies')
),
id = 'container',
style = list(
backgroundColor = '#ff998a'
)
),
html$div(list(
html$h2('Make a selection from the dropdown menu.',
id = 'text-box'),
dccRadioItems(id='radio-partial',
options = list(
list(label = 'All',
value = 'all'),
list(label = 'Do not update colour',
value = 'static')
),
value = 'all')
)
)
)
)
)
app$callback(output=list(
output(id='text-box', property='children'),
output(id='container', property='style')
),
params=list(
input(id='data-dropdown', property='value'),
input(id='radio-partial', property='value')
),
function(value, choice) {
if (is.null(value)) {
return(dashNoUpdate())
}
if (choice == "all" && value == "series") {
style <- list(
backgroundColor = '#ff998a'
)
} else if (choice == "all") {
style <- list(
backgroundColor = '#fff289'
)
} else {
return(list(sprintf("You have chosen %s.", value),
dashNoUpdate()))
}
return(list(sprintf("You have chosen %s.", value),
style))
}
)
app$run_server(debug=TRUE)
"""
def test_rsnu001_multiple_outputs(dashr):
dashr.start_server(app)
dashr.find_element("#data-dropdown").click()
dashr.find_elements("div.VirtualizedSelectOption")[1].click()
dashr.wait_for_text_to_equal(
"#text-box",
"You have chosen series."
)
backgroundColor = dashr.find_element('#container').value_of_css_property("background-color")
assert backgroundColor == "rgba(255, 153, 138, 1)"
dashr.find_element("#data-dropdown").click()
dashr.find_elements("div.VirtualizedSelectOption")[0].click()
dashr.wait_for_text_to_equal(
"#text-box",
"You have chosen movies."
)
backgroundColor = dashr.find_element('#container').value_of_css_property("background-color")
assert backgroundColor == "rgba(255, 242, 137, 1)"
dashr.find_elements("input[type='radio']")[1].click()
dashr.find_element("#data-dropdown").click()
dashr.find_elements("div.VirtualizedSelectOption")[1].click()
dashr.wait_for_text_to_equal(
"#text-box",
"You have chosen series."
)
assert backgroundColor == "rgba(255, 242, 137, 1)"
dashr.find_elements("input[type='radio']")[0].click()
dashr.find_element("#data-dropdown").click()
dashr.find_elements("div.VirtualizedSelectOption")[0].click()
dashr.wait_for_text_to_equal(
"#text-box",
"You have chosen movies."
)
assert backgroundColor == "rgba(255, 242, 137, 1)"