Selenium clear()方法无法清掉数据

问题描述

clear()方法执行过后, 数据还是在.

根本原因

存在镜像节点. 操作clear()清掉数据后, 镜像节点的数据还在, 就会再补充回去. 

解决办法

添加下面代码就可以连同镜像的数据一起去掉.

WebElement ballast = browser.getWebDriver().findElement(By.xpath("xpath"));
ballast.sendKeys(Keys.chord(Keys.CONTROL, "a"));
ballast.sendKeys(Keys.DELETE);    
原文地址:https://www.cnblogs.com/cheese320/p/9141002.html