gradio/demo/sentence_builder.py
Ali Abdalla d4d768e9be End-to-end UI tests with Selenium (#72)
* selenium test file

* selenium test

* added save_to as interface attribute, 4 demo tests with selenium

* change name to test_demos

* fixed wait until, removed path insertion

* added selenium to circleci config

* trying chrome driver image

* removing cache from circlci

* using chromedriver_installer

* adding deps for chromedriver

* sudo

* removed chromedriver

* added chromium-chromedriver

* using chromedriver-py

* using service instead of exec path

* using latest selenium

* using browsers image

* added cwd to tmp and test paths

* saving artifacts

* added tmp.txt

* changed driver size

* elem.text sleep

* driver size fix

* saving artifacts

* saving artifacts correctly

* saving artifacts correctly

* saving artifactS

* print statement

* print statement

* print statement

* correct dir

* debugging

* debugging

* debugging

* fixing wonderful

* running comparison

* current dir fix

* changing longest_word

* fixed longest_word

* clean up

* fixing new output label name

* time limit on while loops

* refactoring common code

* removed setUp

* removed server_port declaration from demos

Co-authored-by: Ali Abid <aliabid94@gmail.com>
2020-10-23 18:28:30 +04:00

30 lines
914 B
Python

# Demo: (Slider, Dropdown, Radio, CheckboxGroup, Checkbox) -> (Textbox)
import gradio as gr
def sentence_builder(quantity, animal, place, activity_list, morning):
return f"""The {quantity} {animal}s went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}"""
io = gr.Interface(
sentence_builder,
[
gr.inputs.Slider(2, 20),
gr.inputs.Dropdown(["cat", "dog", "bird"]),
gr.inputs.Radio(["park", "zoo", "road"]),
gr.inputs.CheckboxGroup(["ran", "swam", "ate", "slept"]),
gr.inputs.Checkbox(label="Is it the morning?"),
],
"text",
examples=[
[2, "cat", "park", ["ran", "swam"], True],
[4, "dog", "zoo", ["ate", "swam"], False],
[10, "bird", "road", ["ran"], False],
[8, "cat", "zoo", ["ate"], True],
])
io.test_launch()
if __name__ == "__main__":
io.launch()