Selenium Web驱动程序

嗨我在运行Selenium网络驱动程序时遇到错误,请帮忙解决

线程“main”中的异常org.openqa.selenium.WebDriverException:元素必须是用户可编辑的才能清除它 . 命令持续时间或超时:103毫秒构建信息:版本:'2.53.0',修订版:'35ae25b',时间:'2016-03-15 17:00:58'系统信息:主机:'anil-PC',ip :'192.168.0.131',os.name:'Windows Vista',os.arch:'x86',os.version:'6.0',java.version:'1.7.0-ea'会话ID:0736ad53-a638- 44e4-a24a-bcda63bb6f4e驱动信息:org.openqa.selenium.firefox.FirefoxDriver Capabilities [{platform = WINDOWS,acceptSslCerts = true,javascriptEnabled = true,browserName = firefox,rotating = false,locationContextEnabled = true,version = 43.0.1, cssSelectorsEnabled =真,databaseEnabled =真,handlesAlerts =真,nativeEvents =假,webStorageEnabled =真,applicationCacheEnabled =真,takesScreenshot =真}]在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)在sun.reflect.NativeConstructorAccessorImpl.newInstance( NativeConstructorAccessorImpl.java:57)at java.lang.reflect.Constructor.n中的sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ewInstance(Constructor.java:531)在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)在org.openqa .selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)在org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)在org.openqa.selenium.remote.RemoteWebElement.clear(RemoteWebElement.java :140)at demo.TestFB.main(TestFB.java:26)引起:org.openqa.selenium.WebDriverException:元素必须是用户可编辑的才能清除它 . 构建信息:版本:'2.53.0',修订版:'35ae25b',时间:'2016-03-15 17:00:58'系统信息:主机:'anil-PC',ip:'192.168.0.131', os.name:'Windows Vista',os.arch:'x86',os.version:'6.0',java.version:'1.7.0-ea'驱动程序信息:driver.version:未知.bot.Error( file:/// C:/Users/anil/AppData/Local/Temp/anonymous9127022654718385403webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:681)at .bot.action.clear(file: ///C:/Users/anil/AppData/Local/Temp/anonymous9127022654718385403webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:11685)at .WebElement.clearElement(file:/// C :/Users/anil/AppData/Local/Temp/anonymous9127022654718385403webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12136)在.DelayedCommand.prototype.executeInternal_ /小时(文件:/// C :/Users/anil/AppData/Local/Temp/anonymous9127022654718385403webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js: 12661)在.DelayedCommand.prototype.executeInternal_(文件:/// C:/Users/anil/AppData/Local/Temp/anonymous9127022654718385403webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12666)在.DelayedCommand.prototype.execute / <(文件:/// C:/Users/anil/AppData/Local/Temp/anonymous9127022654718385403webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12608)

回答(1)

2 years ago

您在一个非用户可编辑的元素上调用clear(),因此该元素不是输入或textarea .

元素必须是用户可编辑的才能清除它 .

来自selenium java docs about clear()

/**
   * If this element is a text entry element, this will clear the value. Has no effect on other
   * elements. Text entry elements are INPUT and TEXTAREA elements.
   *
   * Note that the events fired by this event may not be as you'd expect.  In particular, we don't
   * fire any keyboard or mouse events.  If you want to ensure keyboard events are fired, consider
   * using something like {@link #sendKeys(CharSequence...)} with the backspace key.  To ensure
   * you get a change event, consider following with a call to {@link #sendKeys(CharSequence...)}
   * with the tab key.
   */