MCPcopy Create free account
hub / github.com/dot-agent/nextpy / test_submit

Function test_submit

integration/test_form_submit.py:168–247  ·  view source on GitHub ↗

Fill a form with various different output, submit it to backend and verify the output. Args: driver: selenium WebDriver open to the app form_submit: harness for FormSubmit app

(driver, form_submit: AppHarness)

Source from the content-addressed store, hash-verified

166
167@pytest.mark.asyncio
168async def test_submit(driver, form_submit: AppHarness):
169 """Fill a form with various different output, submit it to backend and verify
170 the output.
171
172 Args:
173 driver: selenium WebDriver open to the app
174 form_submit: harness for FormSubmit app
175 """
176 assert form_submit.app_instance is not None, "app is not running"
177 by = By.ID if form_submit.app_source is FormSubmit else By.NAME
178
179 # get a reference to the connected client
180 token_input = driver.find_element(By.ID, "token")
181 assert token_input
182
183 # wait for the backend connection to send the token
184 token = form_submit.poll_for_value(token_input)
185 assert token
186
187 name_input = driver.find_element(by, "name_input")
188 name_input.send_keys("foo")
189
190 pin_inputs = driver.find_elements(By.CLASS_NAME, "chakra-pin-input")
191 pin_values = ["8", "1", "6", "4"]
192 for i, pin_input in enumerate(pin_inputs):
193 pin_input.send_keys(pin_values[i])
194
195 number_input = driver.find_element(By.CLASS_NAME, "chakra-numberinput")
196 buttons = number_input.find_elements(By.XPATH, "//div[@role='button']")
197 for _ in range(3):
198 buttons[1].click()
199
200 checkbox_input = driver.find_element(By.CLASS_NAME, "chakra-checkbox__control")
201 checkbox_input.click()
202
203 switch_input = driver.find_element(By.CLASS_NAME, "chakra-switch__track")
204 switch_input.click()
205
206 radio_buttons = driver.find_elements(By.CLASS_NAME, "chakra-radio__control")
207 radio_buttons[1].click()
208
209 textarea_input = driver.find_element(By.CLASS_NAME, "chakra-textarea")
210 textarea_input.send_keys("Some", Keys.ENTER, "Text")
211
212 debounce_input = driver.find_element(by, "debounce_input")
213 debounce_input.send_keys("bar baz")
214
215 time.sleep(1)
216
217 prev_url = driver.current_url
218
219 submit_input = driver.find_element(By.CLASS_NAME, "chakra-button")
220 submit_input.click()
221
222 async def get_form_data():
223 return (await form_submit.get_state(token)).substates["form_state"].form_data
224
225 # wait for the form data to arrive at the backend

Callers

nothing calls this directly

Calls 2

rangeFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected