我想知道如何从文本框中删除文本。我从谷歌搜索了很多,但目前什么也没找到。请告诉我任何可以帮助我删除/清理字段中文本的关键字。
您也可以将其用于清除测试字段。
driver.findElement(By.id("textfieldid")).sendKeys(");//空字符串
或
输入文本(您的 Web 元素定位器) ${空}
你不需要机器人来做这件事。只需使用硒。
driver.findElement(By.id("username")).clear();
http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html#clear()
你不需要它。在这里查看
def input_text(self, locator, text):
"""Types the given `text` into text field identified by `locator`.
See `introduction` for details about locating elements. """
self._info("Typing text '%s' into text field '%s'" % (text, locator))
self._input_text_into_text_field(locator, text)
Input Text
关键字调用
_input_text_into_text_field
无论如何,这是发送明确的命令:
def _input_text_into_text_field(self, locator, text):
element = self._element_find(locator, True, True)
element.clear()
element.send_keys(text)