|
本帖最后由 15806019945 于 2017-3-9 11:29 编辑
我写一段自动登录的脚本代码如下
package test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebElement;
public class dl {
/**
* @param args
*/
public static void main(String[] args) {
System.setProperty("webdriver.firefox.bin","E:/Program Files (x86)/Mozilla Firefox/firefox.exe");
System.setProperty("webdriver.gecko.driver","E:/selenium/geckodriver.exe");
WebDriver driver = new FirefoxDriver(); 、
driver.get("http://fuzhou.scity.cn/gate/public/login/login.jsp"); 、
driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys("ceshi");
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys("123456");
driver.findElement(By.id("loginBtn")).click();
}
}
但执行时提示如下错误
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
The method sendKeys(CharSequence...) from the type WebElement refers to the missing type CharSequence
The method sendKeys(CharSequence...) from the type WebElement refers to the missing type CharSequence
at test.dl.main(dl.java:21)
第21行为 driver.findElement(By.id("username")).sendKeys("ceshi");
移到这行提示如下
The method sendKeys(CharSequence...) from the type WebElement refers to the missing type CharSequence
运行的JDK 为 1.8
按网上说的改 Java Compiler,选择1.7版本也不行求大神帮助看一下
|
|