Testing element classes
st.testing.v1.element_tree.Block
The Block
class has the same methods and attributes as AppTest
. A Block
instance represents a container of elements just as AppTest
represents the entire app. For example, Block.button
will produce a WidgetList
of Button
in the same manner as AppTest.button
.
ChatMessage
, Column
, and Tab
all inherit from Block
. For all container classes, parameters of the original element can be obtained as properties. For example, ChatMessage.avatar
and Tab.label
.
Element base class for testing.
This class's methods and attributes are universal for all elements implemented in testing. For example, Caption, Code, Text, and Title inherit from Element. All widget classes also inherit from Element, but have additional methods specific to each widget type. See the AppTest class for the full list of supported elements.
For all element classes, parameters of the original element can be obtained as properties. For example, Button.label, Caption.help, and Toast.icon.
Class description[source] | |
---|---|
st.testing.v1.element_tree.Element(proto, root) | |
Methods | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
Attributes | |
The value or contents of the element. |
Class description[source] | |
---|---|
st.testing.v1.element_tree.Button(proto, root) | |
Methods | |
click() | Set the value of the button to True. |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the button. |
Attributes | |
The value of the button. (bool) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.ChatInput(proto, root) | |
Methods | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the widget. |
Attributes | |
The value of the widget. (str) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.Checkbox(proto, root) | |
Methods | |
check() | Set the value of the widget to True. |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the widget. |
uncheck() | Set the value of the widget to False. |
Attributes | |
The value of the widget. (bool) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.ColorPicker(proto, root) | |
Methods | |
pick(v) | Set the value of the widget as a hex string. May omit the "#" prefix. |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the widget as a hex string. |
Attributes | |
The currently selected value as a hex string. (str) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.DateInput(proto, root) | |
Methods | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the widget. |
Attributes | |
The value of the widget. (date or Tuple of date) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.Multiselect(proto, root) | |
Methods | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
select(v) | Add a selection to the widget. Do nothing if the value is already selected. If testing a multiselect widget with repeated options, use set_value instead. |
set_value(v) | Set the value of the multiselect widget. (list) |
unselect(v) | Remove a selection from the widget. Do nothing if the value is not already selected. If a value is selected multiple times, the first instance is removed. |
Attributes | |
The widget's formatting function for displaying options. (callable) | |
The indices of the currently selected values from the options. (list) | |
The currently selected values from the options. (list) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.NumberInput(proto, root) | |
Methods | |
Decrement the st.number_input widget as if the user clicked "-". | |
Increment the st.number_input widget as if the user clicked "+". | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the st.number_input widget. |
Attributes | |
Get the current value of the st.number_input widget. |
Class description[source] | |
---|---|
st.testing.v1.element_tree.Radio(proto, root) | |
Methods | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the selection by value. |
Attributes | |
The widget's formatting function for displaying options. (callable) | |
The index of the current selection. (int) | |
The currently selected value from the options. (Any) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.SelectSlider(proto, root) | |
Methods | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_range(lower, upper) | Set the ranged selection by values. |
set_value(v) | Set the (single) selection by value. |
Attributes | |
The widget's formatting function for displaying options. (callable) | |
The currently selected value or range. (Any or Sequence of Any) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.Selectbox(proto, root) | |
Methods | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
select(v) | Set the selection by value. |
select_index(index) | Set the selection by index. |
set_value(v) | Set the selection by value. |
Attributes | |
The widget's formatting function for displaying options. (callable) | |
The index of the current selection. (int) | |
The currently selected value from the options. (Any) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.Slider(proto, root) | |
Methods | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_range(lower, upper) | Set the ranged value of the slider. |
set_value(v) | Set the (single) value of the slider. |
Attributes | |
The currently selected value or range. (Any or Sequence of Any) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.TextArea(proto, root) | |
Methods | |
input(v) | Set the value of the widget only if the value does not exceed the maximum allowed characters. |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the widget. |
Attributes | |
The current value of the widget. (str) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.TextInput(proto, root) | |
Methods | |
input(v) | Set the value of the widget only if the value does not exceed the maximum allowed characters. |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the widget. |
Attributes | |
The current value of the widget. (str) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.TimeInput(proto, root) | |
Methods | |
Select the previous available time. | |
Select the next available time. | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the widget. |
Attributes | |
The current value of the widget. (time) |
Class description[source] | |
---|---|
st.testing.v1.element_tree.Toggle(proto, root) | |
Methods | |
run(*, timeout=None) | Run the AppTest script which contains the element. |
set_value(v) | Set the value of the widget. |
Attributes | |
The current value of the widget. (bool) |
Still have questions?
Our forums are full of helpful information and Streamlit experts.