Selenium使用入門(mén)


          ????? Selenium是集成測(cè)試工具,是ThoughtWorks公司(就是馬同學(xué)的那個(gè)公司,牛的很)的開(kāi)源工具,最近在網(wǎng)上看到介紹的文章,自已也用了一下,它主要包括:Selenium IDE,Selenium Remote Control,Selenium Core,主要的思想我個(gè)理解就是在使用中生成測(cè)試報(bào)告,測(cè)試用例,以前對(duì)這種集成測(cè)試也不是很了解,也不知說(shuō)的對(duì)不對(duì),一般對(duì)開(kāi)發(fā),測(cè)試人員來(lái)說(shuō)通過(guò)Selenium IDE來(lái)生成測(cè)試用例中的代碼,然后再運(yùn)junit來(lái)進(jìn)行測(cè)試,它的測(cè)試用例一般為

          package ?com.thoughtworks.selenium;

          import ?junit.framework.TestCase;

          import ?org.openqa.selenium.server.SeleniumServer;

          public ? class ?GoogleTest? extends ?TestCase
          {
          ???
          private ?Selenium?selenium;

          ???
          public ? void ?setUp()? throws ?Exception? {
          ????????String?url?
          = ? " http://www.google.com " ;
          ???????selenium?
          = ? new ?DefaultSelenium( " localhost " ,?SeleniumServer.DEFAULT_PORT,? " *firefox " ,?url);
          ???????selenium.start();
          ????}

          ???
          ???
          protected ? void ?tearDown()? throws ?Exception? {
          ???????selenium.stop();
          ???}

          ???
          ???
          public ? void ?testGoogleTestSearch()? throws ?Throwable? {
          ????????selenium.open(
          " http://www.google.com " );
          ????????assertEquals(
          " Google " ,?selenium.getTitle());
          ????????selenium.type(
          " q " ,? " Selenium?OpenQA " );
          ????????assertEquals(
          " Selenium?OpenQA " ,?selenium.getValue( " q " ));
          ????????selenium.click(
          " btnG " );
          ????????selenium.waitForPageToLoad(
          " 5000 " );
          ????????assertTrue(selenium.isTextPresent(
          " openqa.org " ));
          ????????assertEquals(
          " Selenium?OpenQA?-?Google?搜索 " ,?selenium.getTitle());
          ????}

          ????
          }

          ?可以從setUp()中看到,它需要用到一個(gè)叫SeleniumServer的服務(wù)器,這個(gè)服務(wù)器的作用主要是代理的作用,因?yàn)閟ame origin policy(就是一個(gè)腳本只能在它自已的源站點(diǎn)上運(yùn)行,我這樣理解的,不了的可以查看官方文檔)的關(guān)系,所以需要加一層去取得網(wǎng)頁(yè)并能在上面運(yùn)行測(cè)試腳本的服務(wù)器,也就是我們的SeleniumServer了,所以才叫Selenium Remote Control,我們的測(cè)試用例主要是去連它,而不是真正直接去連接google進(jìn)行的測(cè)試。以后不用想怎么寫(xiě)測(cè)試用例了,Selenium Core主要是寫(xiě)html來(lái)進(jìn)行測(cè)試,不過(guò)同樣也可以用Selenium IDE來(lái)自動(dòng)生成html,然后將生成的一個(gè)html放到一起,開(kāi)啟TestRunner.html進(jìn)行自動(dòng)測(cè)試,速度分三步,run,walk,step,run模式下看上去還是很過(guò)癮的,原來(lái)javascript可以寫(xiě)出這么牛的軟件,呵呵,java6也支持javascript腳本了,看來(lái)這門(mén)語(yǔ)言還是值得好好研究一下,不能總是停留在看得懂的水平。
          注意:上面說(shuō)的服務(wù)器在 \selenium-remote-control-0.8.1\server下面
          啟動(dòng)命令為 java -jar selenium-server.jar
          參數(shù) -interactive 為使用交互模式,就是可以直接在命令行進(jìn)行測(cè)試
          ????????? -multiWindow 為多窗體,我試了下,不過(guò)好像不行

          posted on 2006-09-16 09:40 The One 閱讀(2400) 評(píng)論(6)  編輯  收藏

          評(píng)論

          # re: Selenium使用入門(mén) [未登錄](méi) 2007-05-09 15:31 charles

          非常好呀!
          謝謝,基礎(chǔ)入門(mén)文章。  回復(fù)  更多評(píng)論   

          # re: Selenium使用入門(mén) 2007-05-30 11:02 1

          怎么看不懂呢,能不能說(shuō)的在詳細(xì)點(diǎn)。  回復(fù)  更多評(píng)論   

          # re: Selenium使用入門(mén) 2008-03-13 13:22 alextowxm

          n  回復(fù)  更多評(píng)論   

          # re: Selenium使用入門(mén) [未登錄](méi) 2008-04-15 19:42 Kevin

          能跟你聯(lián)系么 我有一些問(wèn)題想請(qǐng)教你

          ljg624@hotmail.com  回復(fù)  更多評(píng)論   

          # re: Selenium使用入門(mén) 2009-07-22 14:20 Kevin news

          看不懂!!!!  回復(fù)  更多評(píng)論   

          # re: Selenium使用入門(mén) [未登錄](méi) 2010-02-27 14:36 Bill

          Just so so   回復(fù)  更多評(píng)論   


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          <2006年9月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(3)

          隨筆檔案(11)

          相冊(cè)

          我的郵箱

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 乌拉特前旗| 湘潭县| 博湖县| 新田县| 平武县| 东平县| 晋宁县| 贵溪市| 绍兴县| 沿河| 金乡县| 周口市| 弋阳县| 星子县| 章丘市| 博客| 台湾省| 德化县| 白城市| 青冈县| 瑞昌市| 申扎县| 郑州市| 营山县| 嫩江县| 沾益县| 广平县| 青川县| 阿克苏市| 四平市| 喀喇| 调兵山市| 莱芜市| 阿拉善左旗| 永德县| 陆河县| 东乡族自治县| 辉南县| 海林市| 丽水市| 大冶市|