MILY: 宋體; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋體; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">下面說CORE。
安裝過程就不扯了。這個地址已經很明白的告訴了你如何安裝。
你按照這個這樣做,絕對是配置不起來的,知道原因嗎?我告訴你!
正確的做法應該是在
在server.xml中。配置下tomcat的虛擬目錄。
這里我告訴大家一些其他方面
這個地址需要重新配置。道理很簡單,因為你可以根據模塊的不同制定不同的連接機制什么的,然后把你IDE過來的東西全部放到這里進行執行。
那么我就說說這個過程。
上面前3個是系統自帶的html。
根據邏輯。你可以自己去模仿寫,就如我寫的那樣,只要路徑正確就OK
然后自然的你就可以看到并執行了。
希望的是能夠進行模塊化。
下面說下RC。
我這里也僅僅是模擬著做。
Rc的安裝很簡單。
1. 去下載rc包。我下的是1.0.1
2. 然后用命令行進入
D:\selenium-remote-control-1.0.1-dist\selenium-remote-control-1.0.1\selenium-server-1.0.1目錄。然后輸入:
java –jar selenium-server.jar.
這樣啟動好。
打開你的myeclipse,然后新建項目,新建包,新建一個junit的class
加入你們的junit 4的包和selenium的包
看明白了。selenium只要一個jar包就夠了
然后把你IDE錄制的代碼拷入
但是,請注意:
IDE是這樣。
package com.example.tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class Untitled extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://dev.bizcn.com/", "*chrome");
}
public void testUntitled() throws Exception {
selenium.open("/");
selenium.type("login_name", "jie");
selenium.click("http://input[@type='image']");
selenium.waitForPageToLoad("30000");
}
}
但是放入到myeclipse就應該是下面這樣。
package selenium;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
import junit.framework.TestCase;
public class Caichang extends TestCase {
private Selenium selenium;
protected void tearDown() throws Exception {
selenium.stop();
}
/* public void setUp() throws Exception {
String url = "http://www.google.cn/";
selenium = new DefaultSelenium("localhost", 4444, "*iehta", url); //4444 is default server port
selenium.start();
//setUp("http://change-this-to-the-site-you-are-testing/", "*chrome");
}
public void testUntitled2() throws Exception {
selenium.open("/webhp?hl=zh-CN&source=hp&btnG=Google+%E6%90%9C%E7%B4%A2");
selenium.type("q", "java");
selenium.click("btnG");
}*/
public void setUp() throws Exception {
String url = "http://dev.bizcn.com/";
selenium = new DefaultSelenium("localhost", 4444, "*iehta", url); //4444 is default server port
selenium.start();
//setUp("http://change-this-to-the-site-you-are-testing/", "*chrome");
}
public void testUntitled() throws Exception {
selenium.open("/");
selenium.type("login_name", "jie");
assertEquals("caichang",selenium.getTitle());
selenium.click("http://input[@type='image']");
assertEquals("button",selenium);
selenium.waitForPageToLoad("30000");
}
}
注意setUp方法的區別和前面加的東西。
至于assertEquals("caichang",selenium.getTitle());和 assertEquals("button",selenium);
是我加的,也就是junit的斷言。
哥們,如果你junit不熟悉,那這個就沒辦法繼續下去了
然后下面的你想要做成什么樣子,那就看你了,斷言自己加,要什么自己就按照junit的規則進行書寫吧!
說下總結:
1. 我也是在不斷的學習中。如果上面文檔有什么不好的地方,指出來下。
2. Selenium rc的高級操作,這個需要一些junit的東西了。這個我也是要慢慢的學。目前還不能給大家很好的例子什么的。
3. IDE的操作我希望是模塊化,這樣你維護起來或者交互給客戶的時候很方便運用。
4. Selenium更多的是用在驗收測試中,所以我覺得一定要你系統穩定了,不會有大變化的情況下做。不然。。。。后果是痛苦的。。
文章來源于領測軟件測試網 http://www.kjueaiud.com/