51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 1526|回复: 1
打印 上一主题 下一主题

求大神帮助(WebElement sendKeys 用法)

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2017-3-8 17:02:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 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版本也不行求大神帮助看一下
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

  • TA的每日心情
    开心
    2017-3-22 10:48
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    2#
    发表于 2017-3-21 17:02:09 | 只看该作者
    你注册过这个账号了吗? 只有注册过才能登陆进去,用户名要求是6-18位字母、数字或者下划线,你输入的值不符合要求。

    评分

    参与人数 1测试积点 +10 收起 理由
    lsekfe + 10 积极回复获得测试积点10 赶快去商城换取奖.

    查看全部评分

    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-5-3 21:51 , Processed in 0.067206 second(s), 25 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表