TA的每日心情 | 郁闷 2017-9-11 10:41 |
---|
签到天数: 16 天 连续签到: 1 天 [LV.4]测试营长
|
本帖最后由 琥珀水晶 于 2017-4-12 17:28 编辑
登录之后,定位元素运行时报错。请帮忙看一下,谢谢。(登录之前正常)
package test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import com.thoughtworks.selenium.Wait;
public class test1 {
public static void main(String[] args) throws InterruptedException {
System .setProperty("webdriver.chrome.driver",
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver1.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://localhost:8080/TestOA/userAction_toIndex.action");
System.out.print("page title is"+driver.getTitle());
driver.findElement(By.name("loginName")).sendKeys("admin");//用户名
driver.findElement(By.name("password")).sendKeys("1234");//密码
driver.findElement(By.xpath("//*[@id='LoginInfo']/table/tbody/tr[2]/td[3]/input")).click();//点击登录
Thread.sleep(5000);
WebElement aboutlink = driver.findElement(By.linkText("岗位管理"));
aboutlink.click();
//driver.close();
}
}
|
|