Selenium定位不了腾讯首页登录的IFrame元素?
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: #switcher_ploginFor documentation on this error, please visit: No Such Element
public static void main(String[] args) {
System.out.println("start login");
System.setProperty("webdriver.gecko.driver", "E://Selenium//geckodriver-v0.11.1-win64//geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://qq.com");
WebElement loginLayout = driver.findElement(By.cssSelector("a"));
loginLayout.click();
driver.switchTo().frame("login_frame");//进入IFrame
WebElement loginByAccount = driver.findElement(By.id("switcher_plogin"));
loginByAccount.click();
}
试一下xpath 等大神来 是不是有iframe嵌套? 用xpath 查找原因 使用xpath
页:
[1]