使用sendKey方法时出现The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String) 错误提示

 1 package SeleniumTestProject;
 2 
 3 import java.util.Timer;
 4 import org.openqa.selenium.*;
 5 import org.openqa.selenium.chrome.ChromeDriver;
 6 import org.yaml.snakeyaml.events.Event.ID;
 7 
 8 public class Test01 {
 9     protected String WebURL = "https://caiyun.feixin.10086.cn/";   //存放网址
10     public WebDriver driver;                                       //定义一个driver字段
11     //初始化浏览器驱动
12     public void InitDriver() {
13         System.setProperty("webdriver.chrome.driver", "C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe");
14         driver = new ChromeDriver();
15         driver.get(WebURL);
16         driver.manage().window().maximize();
17         String title = driver.getTitle();
18         System.out.print(title);
19     }
20     public void InputBox() {
21         driver.findElement(By.id("account")).sendKeys("15875303116");
22     }
23     public static void main(String[] args){
24         Test01 t = new Test01();
25         t.InitDriver();
26         
27 
28     }
29 }

使用默认配置的eclipse编译这段代码时,21行sendKeys方法报错,提示The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String),后面查了一下,是编译器的问题,右键项目包,点击Build Path里的Configure Build Path,更改Java Compiler里的Compiler compliance level为1.7(如下图),点击应用后就可以解决

使用sendKey方法时出现The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String) 错误提示

使用sendKey方法时出现The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String) 错误提示

上一篇:2019年中国高校计算机大赛 - 移动应用创新赛


下一篇:jQuery移动光标改变图像