這是我的腳本。同時點擊一個使用其xpath的鏈接不工作&會拋出一個錯誤「找不到ERROR元素」,但在Selenium IDE中運行良好。錯誤:未找到元素在Selenium IDE中運行良好,但在Selenium RC中未運行。獲取錯誤
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;
public class testGoogle extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.co.in/");
selenium.start();
selenium.windowFocus();
selenium.windowMaximize();
}
@Test
public void testUntitled() throws Exception {
selenium.open("http://www.google.co.in/");
selenium.waitForPageToLoad("30000");
assertEquals("Google", selenium.getTitle());
selenium.click("name=q");
selenium.type("name=q", "Software Testing");
selenium.click("name=btnK");
selenium.click("//html/body/div[4]/div/div/div[4]/div[3]/div[2]/div/div[2]/div/ol/li[2]/div/h3/a"); // ERROR: Element Not Found
selenium.waitForPageToLoad("30000");
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}