Selenium,sendKeys到一个看不见但被选中的元素

时间:2017-11-14 16:19:51

标签: selenium-webdriver textarea sendkeys

我正在尝试将key发送到一个元素(areaText),但我一直收到错误,说areaText不可见,但我可以在元素之前使用TAB选择此元素(键盘光标显示在textArea上可用),甚至在此之后它发送给我错误。这是代码:

driver.findElement(By.name("wla-value-for-id_15")).sendKeys("release");
WebElement tab = driver.findElement(By.name("wla-value-for-id_15"));
tab.sendKeys(Keys.TAB);

driver.findElement(By.id("comment")).sendKeys("projeto");

这是错误:

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: Element is not visible
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'FT-GABRIEL', ip: '105.103.51.96', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_151'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\gabriel.s\AppData\Local\Temp\rust_mozprofile.4415jYdMZ26S, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, moz:headless=false, platform=ANY, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=57.0, platformVersion=6.1, moz:processID=12776.0, browserName=firefox, javascriptEnabled=true, platformName=windows_nt, moz:webdriverClick=false}]
Session ID: 19e3b491-a160-4515-9318-2f0e6d5cf9ab
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:150)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:115)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:272)
    at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:96)
    at testPackage.FireFoxTest.main(FireFoxTest.java:70)

感谢每一位支持

0 个答案:

没有答案