【发布时间】:2014-01-09 11:16:11
【问题描述】:
package testproject;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class WeblinkTest {
public static void main(String[] args) throws InterruptedException {
// Creating a fierfox driver/window
WebDriver driver= new FirefoxDriver();
//Assigning address of the webpage which you want to check
driver.get("https://www.google.co.in/");
Thread.sleep(2000);
//Creating and Identifing--By.xpath the element on which you want testing
WebElement wb1= driver.findElement(By.xpath(".//*[@id='gb']/div[1]/div[1]/div[1]/div[2]"));
wb1.click();
Thread.sleep(2000);
}
}
今天我试图测试 Google 主页 (www.google.co.in) 上提供的 gmail 链接。我能够启动一个 fierfox 窗口,并且它能够执行将我带到 google 主页的第一步,但之后什么都没有发生,我也没有收到任何运行时错误或 eclipse 的任何异常。不知道 webdriver 发生了什么。 我已经在 stakwave 上发布了另外一个程序的问题,所以如果你可以的话,请看看这个链接-Why my test is throwing Exception-Unable to locate element in webdriver?
【问题讨论】:
-
您是否确认您从 Fearfox 获得的
WebElement仍然是正确的?网页往往会在一夜之间发生变化。 -
@zapl ya 我已经在 firebug 和 selenium 的帮助下验证了它,即(两个 firefox 插件)
标签: java eclipse firefox selenium selenium-webdriver