因为项目需要,最近开始学习Selenium,发现Selenium不如它主页说的那么好,只是在处理弹出窗口上就很让人头痛。
我利用selenium-core-1.0.1来熟悉各种Java方法,但是在实际编码中遇到问题,不知道如何解决.
package com.thoughtworks.selenium.corebased;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;
public class TestClick extends SeleneseTestCase {
private static final String BASE_SERVER_PATH = "C:\\selenium-core-1.0.1\\tests";
private static final String TEST_FILE =
BASE_SERVER_PATH + "\\html\\test_click_page1.html";
private Selenium browser =
new DefaultSelenium("localhost", 4444, "iexplore", TEST_FILE);
private SeleniumServer seleniumServer;
public void setUp() throws Exception{
seleniumServer = new SeleniumServer();
seleniumServer.start();
browser.start();
}
public void tearDown() throws Exception{
browser.stop();
seleniumServer.stop();
}
public void testClick() throws Throwable {
browser.open(TEST_FILE);
verifyEquals("Click here for next page", browser.getText("link"));
}
}
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;
public class TestClick extends SeleneseTestCase {
private static final String BASE_SERVER_PATH = "C:\\selenium-core-1.0.1\\tests";
private static final String TEST_FILE =
BASE_SERVER_PATH + "\\html\\test_click_page1.html";
private Selenium browser =
new DefaultSelenium("localhost", 4444, "iexplore", TEST_FILE);
private SeleniumServer seleniumServer;
public void setUp() throws Exception{
seleniumServer = new SeleniumServer();
seleniumServer.start();
browser.start();
}
public void tearDown() throws Exception{
browser.stop();
seleniumServer.stop();
}
public void testClick() throws Throwable {
browser.open(TEST_FILE);
verifyEquals("Click here for next page", browser.getText("link"));
}
}