selenium 3 sendKeys 报错
本帖最后由 15806019945 于 2018-4-6 19:50 编辑http://bbs.51testing.com/data/attachment/common/cf/115428zlxbs417nqzllqal.jpg
本帖最后由 15806019945 于 2017-3-9 11:29 编辑selenium 3.08 +java 8
我写一段自动登录的脚本代码如下
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("ceshi1");
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("ceshi1");
移到这行提示如下
The method sendKeys(CharSequence...) from the type WebElement refers to the missing type CharSequence
运行的JDK 为 1.8
按网上说的改 Java Compiler,选择1.7版本也不行求大神帮助看一下
我也遇到这个问题了 如楼主解决了 望回复 谢谢 我的已解决 把Eclipse换成4.7看下 jdk依旧用的1.8 总算是搞定的在myeclipes 相应工程下设置两个jaK不懂看图
页:
[1]