Selenium2相关疑问

1. 为什么用name属性找不到登陆按钮,但是用By.LinkText找的到

WebDriver driver = new FirefoxDriver();

Navigation navigation = driver.navigate();
navigation.to("http://www.baidu.com");
Thread.sleep(8000);
WebElement webElement =  driver.findElement(By.name("tj_login") );

webElement.click();


2. 为什么是否记住密码这个选项是否选择都是false.

WebDriver driver = new FirefoxDriver();
Navigation navigation = driver.navigate();
navigation.to("https://www.baidu.com/");
WebElement webElement = driver.findElement(By.linkText("登录"));
webElement.click();
Thread.sleep(3000);
webElement = driver.findElement(By.id("TANGRAM__PSP_8__memberPassLabel"));
System.out.println("webElement.isSelected1()"+webElement.isSelected());
webElement.click();
System.out.println("webElement.isSelected2()"+webElement.isSelected());

3.public WebDriver driver = new WebDriver(); 会报错can't initiate the type WebDriver.因为WebDriver是接口,不是类。而接口中有未实现的空方法,不能初始化。

4.Cannot make a static reference to the non-static field driver 静态方法中不能有非静态变量。

5.Selenium-java 2.44版本适用于firefox 33.

6. org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 49 milliseconds
原因:不能唯一定位元素,有多个元素符合定位要求。解决方式:唯一指定元素



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值