MCPcopy Create free account
hub / github.com/pywebio/PyWebIO / test_input

Function test_input

test/template.py:602–735  ·  view source on GitHub ↗

测试输入:: run template.basic_input() actions(['Continue']) template.background_input() # 或者 await template.coro_background_input() / flask_coro_background_input

(browser: Chrome, enable_percy=False, action_delay=0.5)

Source from the content-addressed store, hash-verified

600
601
602def test_input(browser: Chrome, enable_percy=False, action_delay=0.5):
603 """测试输入::
604
605 run template.basic_input()
606 actions(['Continue'])
607 template.background_input() # 或者 await template.coro_background_input() / flask_coro_background_input
608
609 """
610 browser.find_element(By.CSS_SELECTOR, '#input-container input').send_keys("22")
611 browser.find_element(By.TAG_NAME, 'form').submit()
612
613 time.sleep(action_delay)
614 browser.find_element(By.CSS_SELECTOR, '#input-container input').send_keys("secret")
615 browser.find_element(By.TAG_NAME, 'form').submit()
616
617 time.sleep(action_delay)
618 browser.find_element(By.TAG_NAME, 'form').submit()
619
620 # checkbox
621 time.sleep(action_delay)
622 browser.execute_script("arguments[0].click();", browser.find_element(By.CSS_SELECTOR, '#input-container input'))
623 browser.find_element(By.TAG_NAME, 'form').submit()
624
625 # Text Area
626 time.sleep(action_delay)
627 browser.find_element(By.CSS_SELECTOR, '#input-container textarea').send_keys(" ".join(str(i) for i in range(20)))
628 browser.find_element(By.TAG_NAME, 'form').submit()
629
630 # file
631 time.sleep(action_delay)
632 img_path = path.join(here_dir, 'assets', 'img.png')
633 browser.find_element(By.CSS_SELECTOR, '#input-container input').send_keys(img_path)
634 browser.find_element(By.TAG_NAME, 'form').submit()
635
636 # text
637 time.sleep(action_delay)
638 browser.find_element(By.CSS_SELECTOR, '#input-container input').send_keys("text")
639 browser.find_element(By.TAG_NAME, 'form').submit()
640
641 # 表单取消
642 time.sleep(action_delay)
643 browser.execute_script("arguments[0].click();", browser.find_element(By.CSS_SELECTOR, '.pywebio_cancel_btn'))
644
645 # valid func, age in [10, 60]
646 time.sleep(action_delay)
647 browser.find_element(By.CSS_SELECTOR, '#input-container input').send_keys("1")
648 browser.find_element(By.TAG_NAME, 'form').submit()
649 time.sleep(action_delay)
650 browser.find_element(By.CSS_SELECTOR, '#input-container input').clear()
651 browser.find_element(By.CSS_SELECTOR, '#input-container input').send_keys("90")
652 browser.find_element(By.TAG_NAME, 'form').submit()
653 time.sleep(action_delay)
654 browser.find_element(By.CSS_SELECTOR, '#input-container input').clear()
655 browser.find_element(By.CSS_SELECTOR, '#input-container input').send_keys("23")
656 browser.find_element(By.TAG_NAME, 'form').submit()
657
658 # code
659 time.sleep(action_delay)

Callers

nothing calls this directly

Calls 3

SelectClass · 0.85
get_visible_formFunction · 0.85
submitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…