不能進入谷歌搜索頁面,用下面的代碼獲得的org.openqa.selenium.ElementNotVisibleException
例外谷歌搜索org.openqa.selenium.ElementNotVisibleException在谷歌搜索
:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.List;
public class GoogleTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get("google.co.in/");
driver.manage().window().maximize(); driver.findElement(By.xpath("//*[@id='sb_ifc0']")).sendKeys("selenium");
driver.findElement(By.xpath("//*[@id='sblsbb']/button")).click();
List<WebElement> allLinks = driver.findElements(By.tagName("a"));
System.out.println(allLinks.size());
for(int i=0;i<allLinks.size();i++)
{
System.out.println(allLinks.get(i).getText()+"----"+allLinks.get(i).isDisplayed());
}
}
}