简体   繁体   English

org.openqa.selenium.NoSuchElementException WebDriver是否在Java中?

[英]org.openqa.selenium.NoSuchElementException WebDriver in Java?

I have a problem with WebDriver Java class, when I want to get an attribute type "textArea" 当我想要获取属性类型“ textArea”时,WebDriver Java类出现问题

I get this Exception. 我得到这个异常。

Code: 码:

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");

Exception: 例外:

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)

The reason it ain't working is cause the element where u need to enter text is in a iframe. 它无法正常工作的原因是,您需要在其中输入文本的元素位于iframe中。 Please try out following code: 请尝试以下代码:

driver.switchTo().frame(
        driver.findElements(By.tagName("iframe")).get(0));
WebElement descriptionOne = driver
    .findElement(By.className("editbox"));
descriptionOne.sendKeys("Hola! :D");

As per your code, you are calling wrong webElement name to sendkeys: 根据您的代码,您在给sendkeys调用错误的webElement名称:

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");

Please use "descriptionOne.sendKeys("Hola! :D");" 请使用“ descriptionOne.sendKeys(“ Hola!:D”);“ instead of "descripcionUno.sendKeys("Hola! :D");" 而不是“ descripcionUno.sendKeys(“ Hola!:D”);“

Let me know if it works for you. 请让我知道这对你有没有用。 Cheers! 干杯!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.openqa.selenium.NoSuchElementException - org.openqa.selenium.NoSuchElementException webdriver org.openqa.selenium.NoSuchElementException:无法找到元素: - webdriver org.openqa.selenium.NoSuchElementException: Unable to locate element: WebdriverIO 和 Java - IFrame 中的 org.openqa.selenium.NoSuchElementException - WebdriverIO & Java - org.openqa.selenium.NoSuchElementException in IFrame 如何解决org.openqa.selenium.NoSuchElementException - How to solve the org.openqa.selenium.NoSuchElementException org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element error using Selenium through Java - org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element error using Selenium through Java org.openqa.selenium.NoSuchElementException:没有这样的元素:尝试使用Java通过Selenium登录时无法找到元素 - org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element while trying to login through Selenium with Java org.openqa.selenium.NoSuchElementException 导航到子 div Selenium Java - org.openqa.selenium.NoSuchElementException when navigating to child div Selenium Java 如何解决 Selenium 中的 org.openqa.selenium.NoSuchElementException? - How to resolve org.openqa.selenium.NoSuchElementException in Selenium? IE11的org.openqa.selenium.NoSuchElementException - org.openqa.selenium.NoSuchElementException for IE11 org.openqa.selenium.NoSuchElementException:无法找到元素错误 - org.openqa.selenium.NoSuchElementException: Unable to locate element error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM