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
原因:不能唯一定位元素,有多个元素符合定位要求。解决方式:唯一指定元素