【发布时间】:2015-03-15 07:29:09
【问题描述】:
我正在尝试自动化 gmail 登录。
当我使用sendKeys() 在用户名输入框中输入文本时,它会引发异常。
我的代码:
WebElement userName = driver.findElement(By.id("Email"));
userName.sendKeys("tutorial");
例外:
Error:The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String) at com.gmail.test.Gmaillogin.main(Gmaillogin.java:65)
【问题讨论】:
-
基于该 sn-p,它应该可以工作。 String 是 CharSequence ,因此传入字符串文字绝对是使用该方法的正确方法。也许提供更多的周围代码可能会揭示更多?编辑:另外,您使用的是什么 IDE,它的编译器级别是什么?
-
感谢您的回答。我正在使用 Eclipse helios IDE。编译器合规级别为 1.4 。但是,它仍然无法正常工作。
-
尝试将编译器级别更改为 1.7。较旧的 java 版本在功能上存在差异,有时会产生意想不到的结果。
标签: java sendkeys charsequence