Java 中的 org.openqa.selenium.NoSuchElementException WebDriver? [英] org.openqa.selenium.NoSuchElementException WebDriver in Java?
本文介绍了Java 中的 org.openqa.selenium.NoSuchElementException WebDriver?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我想获取属性类型textArea"时,WebDriver Java 类有问题
I have a problem with WebDriver Java class, when I want to get an attribute type "textArea"
我收到此异常.
代码:
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.cmmazzoni.it/index.php?option=com_jdownloads&Itemid=0&view=upload");
WebElement descriptionOne=driver.findElement(By.name("description"));
descripcionUno.sendKeys("Hola! :D");
异常:
java.lang.UnsupportedOperationException: You may only set the value of elements that are input elements
at org.openqa.selenium.htmlunit.HtmlUnitKeyboard.sendKeys(HtmlUnitKeyboard.java:82)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.sendKeys(HtmlUnitWebElement.java:343)
at Modelo.HiloPaginas.subibirImagencom_jdownloads(HiloPaginas.java:219)
at Modelo.HiloPaginas.run(HiloPaginas.java:108)
推荐答案
根据你的代码,你调用了错误的 webElement 名称来发送键:
As per your code, you are calling wrong webElement name to sendkeys:
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.cmmazzoni.it/index.php?option=com_jdownloads&Itemid=0&view=upload");
WebElement descriptionOne=driver.findElement(By.name("description"));
descripcionUno.sendKeys("Hola! :D");
请使用"descriptionOne.sendKeys("Hola!:D");"而不是 "descripcionUno.sendKeys("Hola!:D");"
Please use "descriptionOne.sendKeys("Hola! :D");" instead of "descripcionUno.sendKeys("Hola! :D");"
告诉我它是否适合您.干杯!
Let me know if it works for you. Cheers!
这篇关于Java 中的 org.openqa.selenium.NoSuchElementException WebDriver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文