在selenium webdriver中使用JavascriptExecutor时出现非法字符异常

时间:2014-01-25 04:20:20

标签: javascript selenium

我正在使用Selenium webdriver(2.37.0)来自动化一个Web表单。使用JavascriptExecutor在select选项中设置某个值,如下所示:

if (driver instanceof JavascriptExecutor)
 {

    js = (JavascriptExecutor)driver;
 }

    js.executeScript("document.getElementById('ddlRegCategory').value = 'XYZ';​​​​​​​​​​");

我在上面的脚本行上遇到非法字符异常。

org.openqa.selenium.WebDriverException:非法字符

命令持续时间或超时:25毫秒 构建信息:版本:'2.37.0',修订版:'a7c61cb',时间:'2013-10-18 17:14:00' 系统信息:主机:'mitalee-PC',ip:'169.254.147.196',os.name:'Windows 7',os.arch:'x86',os.version:'6.1',java.version:'1.7 0.0' 会议ID:b98a4393-d1eb-4f21-93bd-87248e58228b 驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver 功能[{platform = XP,acceptSslCerts = true,javascriptEnabled = true,browserName = firefox,rotate = false,locationContextEnabled = true,version = 26.0,cssSelectorsEnabled = true,databaseEnabled = true,handlesAlerts = true,browserConnectionEnabled = true,nativeEvents = true ,webStorageEnabled = true,applicationCacheEnabled = true,takesScreenshot = true}]     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)     在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)     在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)     在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)     在org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:463)     在HRMS.main(HRMS.java:39) 引起:org.openqa.selenium.remote.ErrorHandler $ UnknownServerException:非法字符

0 个答案:

没有答案