Skip to content

Commit 7c66668

Browse files
committed
Add the input() method as a shorter version of update_text()
1 parent 4c04546 commit 7c66668

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,26 @@ def type(self, selector, text, by=By.CSS_SELECTOR,
248248
by = By.XPATH
249249
self.update_text(selector, text, by=by, timeout=timeout, retry=retry)
250250

251+
def input(self, selector, text, by=By.CSS_SELECTOR,
252+
timeout=None, retry=False):
253+
""" Same as update_text(). """
254+
if not timeout:
255+
timeout = settings.LARGE_TIMEOUT
256+
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
257+
timeout = self.__get_new_timeout(timeout)
258+
if page_utils.is_xpath_selector(selector):
259+
by = By.XPATH
260+
self.update_text(selector, text, by=by, timeout=timeout, retry=retry)
261+
251262
def update_text(self, selector, new_value, by=By.CSS_SELECTOR,
252263
timeout=None, retry=False):
253264
""" This method updates an element's text field with new text.
254-
Has two parts:
255-
1. Clears the text field.
256-
2. Types in new text into the text field.
265+
Has multiple parts:
266+
* Waits for the element to be visible.
267+
* Waits for the element to be interactive.
268+
* Clears the text field.
269+
* Types in the new text.
270+
* Hits Enter/Submit (if the text ends in "\n").
257271
@Params
258272
selector - the selector of the text field
259273
new_value - the new value to type into the text field

0 commit comments

Comments
 (0)