Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium Robot框架:如何清除Textfield中的文本_Selenium_Selenium Webdriver_Robotframework - Fatal编程技术网

Selenium Robot框架:如何清除Textfield中的文本

Selenium Robot框架:如何清除Textfield中的文本,selenium,selenium-webdriver,robotframework,Selenium,Selenium Webdriver,Robotframework,我想知道如何从文本框中删除文本。我在谷歌上做了很多搜索,但目前没有找到。请告诉我任何可以帮助我删除/清除字段中文本的关键字。您不需要机器人来完成此操作。。只要使用硒 driver.findElement(By.id("username")).clear(); 您也可以将其用于清除测试字段 driver.findElement(By.id(“textfieldid”)).sendKeys(“”)//空字符串 或 输入文本(您的web元素定位器)${empty} 你不需要它 输入文本关键字正在调用

我想知道如何从文本框中删除文本。我在谷歌上做了很多搜索,但目前没有找到。请告诉我任何可以帮助我删除/清除字段中文本的关键字。

您不需要机器人来完成此操作。。只要使用硒

driver.findElement(By.id("username")).clear();

您也可以将其用于清除测试字段

driver.findElement(By.id(“textfieldid”)).sendKeys(“”)//空字符串

输入文本(您的web元素定位器)${empty}

你不需要它

输入文本
关键字正在调用

_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)    

他可能在说(关键字驱动的selenium包装器),你可能是对的@ErkiM。当selenium拥有
#clear()
时,使用它是非常不必要的:)他并不是仅仅为了这样做而使用Robot框架。他问如何在机器人框架内完成这项工作。来回答使用关键字清除元素文本当我执行库时,我得到错误“ImportError:没有名为keywordgroup的模块”@Erki MI认为user@user3283976建议的解决方案应该有效。这是使用空字符串执行输入文本关键字。我想说的是,如果您想在向文本字段发送键之前清除文本字段,则无需执行此操作,因为输入文本关键字已经在处理它。现在,当我使用此输入文本//*[@name='resolution']编辑时,我收到错误“StaleElementReferenceException”。
def _input_text_into_text_field(self, locator, text):
    element = self._element_find(locator, True, True)
    element.clear()
    element.send_keys(text)