你确定要得到你的意见并填充它吗?
喜欢:
WebElement input = driver.findElement(By.xpath("//input[@class='GOBLEOOO']"));
input.sendKeys("How are you?");
所以,你可以得到你的元素这样的:
WebElement inputByValue = driver.findElement(By.xpath("//input[@value='my text']"));
,或者你有另一种方式来做到这一点
WebElement inputByValue= driver.findElement(By.xpath("//input[contains(@value,'my text')]"));
返回true,如果该值你的属性@value
包含下一个参数(字符串)
因为总有一个value attribute
在input
,因为你如果要找到与您可以使用此XPath输入字段中键入的值的元素类型的值。 Here for more Input specs.
。
// you get the value you typed in the input
String myValue = driver.findElement(By.xpath("//input[@class='GOBLEOOO']")).getAttribute("value");
//you get a element that contains myValue into his attributes
WebElement element = driver.findElement(By.xpath("//*[contains(@id ,myValue) or contains(@value, myValue) or contains(@name, myValue)]"));
您使用的硒? – e1che 2013-04-23 08:20:17
@ e1che:是的,我可以用 – user2251831 2013-04-23 08:20:44
来获取你的html吗? – e1che 2013-04-23 08:23:42