def find_write(driver, elem_path, write_str, clear_first=True, send_enter=False,
by=CSS, timeout=TIMEOUT, poll_frequency=0.5):
""" Find a writable element and write to it
find_write locates a writable element on the page, waiting
for up to timeout seconds. Once found, it writes the string
to it.
Args:
driver (selenium webdriver or element): A driver or element
elem_path (str): String used to located the element
write_str (str): String to write
clear_first (bool): Clear the contents before writing (default True)
send_enter (bool): Send a keyboard ENTER after writing string
by (selenium By): Selenium By reference
timeout (int): Selenium Wait timeout, in seconds
poll_frequency (float): Selenium Wait polling frequency, in seconds
Returns:
element: Selenium element
Raises:
TimeoutException: Raised when target element isn't located
"""
elem = find_element(driver, elem_path=elem_path, by=by, timeout=timeout,
poll_frequency=poll_frequency)
if clear_first:
elem.clear()
elem.send_keys(write_str)
if send_enter:
elem.send_keys(Keys.ENTER)
return elem
评论列表
文章目录