我是JUnit Selenium中的新成员,并且发现问题。 我在@Test方法中找不到使用locator的元素。当我输入driver.
时我没有预测性搜索,如果我输入@Before
即可。无法在@Test中使用定位器Junit Selenium网络驱动程序
E.g我不能类型
@Test
..
driver.findElement(By.id("gs_htif0")).sendKeys("blabla");
我的类包含 -
@Before
public void setUp() throws Exception {
WebDriver driver;
System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");
driver = new FirefoxDriver();
String baseURL = "https://www.google.com";
driver.get(baseURL);
}
@Test
public void test() {
driver.**___PROBLEM___**
}
@After
public void tearDown() throws Exception {
}
。 – JeffC