Selenium+Java元素定位之二

//经过彻底匹配连接来定位
driver.findElement(By.linkText("新闻")).click();
//经过部分匹配连接来定位
driver.findElement(By.partialLinkText("新")).click();
//经过xpath方式进行定位
driver.findElement(By.xpath(".//*[@id='kw']")).sendKeys("selenium");

//经过css方式进行定位
driver.findElement(By.cssSelector("#kw")).sendKeys("时光");

相关文章
相关标签/搜索