【发布时间】:2018-09-10 16:51:35
【问题描述】:
我正在尝试先打开 google.com,然后输入“selenium testing”。
我只想在使用 eclipse 的 webdriver 中使用 className,但出现以下错误。
Exception in thread "main"
org.openqa.selenium.NoSuchElementException: Unable to locate element:
{"method":"class name","selector":"Tg7LZd"}
Command duration or timeout: 37 milliseconds
这是我的代码:
package coreJava;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Training1 {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
driver.findElement(By.className("gLFyf")).sendKeys("selenium testing");
driver.findElement(By.className("Tg7LZd")).click();
}
}
我该如何解决这个问题?
【问题讨论】:
标签: selenium google-chrome selenium-webdriver webdriver selenium-chromedriver