2013-08-28 45 views

回答

3

Selenium-Core有一個擴展:「include」,它可以將另一個測試的內容添加到當前測試中。 以下是OpenQA wiki上的頁面:http://wiki.openqa.org/display/SEL/include,但不幸的是目前無法訪問。 我曾經在過去使用它,但最終放棄了ROLLUP RULES。

但是,如果您正在尋找一種在多個測試用例中重用腳本的方法,我強烈建議您使用匯總規則。這是Selenium IDE的許多用戶功能非常強大和低估的。

使用匯總規則的詳細信息寫在Selenium IDE的幫助頁面上:菜單幫助 - UI元素文檔,然後按關鍵字「彙總」進行搜索。

+0

謝謝,我會盡力的。 – Faiyaz

0

我最終使用了Yevgen建議的Rollups。我花了一些時間來找到實現這一點的正確方法。基本思想是編寫一個JavaScript文件,並將其添加到Selenium IDE的Selenium Core Extensions設置下的options/options下。您需要編寫的JavaScript文件才能構建「可重用的命令堆棧」,這將允許您使用內置彙總命令,並將目標設置爲您分配給一組命令的標籤。

我寫了一篇關於Selenium IDE Includes AKA Rollups的文章,可能是一個有用的資源。

一個例子彙總腳本:

/** 
* For use in Selenium IDE. 
* 
* You will need to add this to Selenium under Options/Options in the Selenium Menu. 
* Put this under Selenium Core Extensions: 
* ~/selenium-ide-for-slp/sideflow.js , ~/selenium-ide-for-slp/slp_rollups.js 
* 
* 
*/ 
var manager = new RollupManager(); 


/** 
* check_for_syntax_errors 
* 
* This rollup tests for php syntax errors, warnings, and notices. 
*/ 
manager.addRollupRule({ 
    name: 'check_for_syntax_errors', 
    description: 'Check for PHP syntax errors, notices, warnings.', 
    args: [], 
    commandMatchers: [], 
    getExpandedCommands: function(args) { 
     var commands = []; 

     commands.push({ 
      command: 'assertNotText', 
      target: '//body', 
      value: '*Notice: Undefined*' 
     }); 

     commands.push({ 
      command: 'assertNotText', 
      target: '//body', 
      value: '**Notice: Trying to get*' 
     }); 

     commands.push({ 
      command: 'assertNotText', 
      target: '//body', 
      value: '*Notice: Use of*' 
     }); 

     commands.push({ 
      command: 'assertNotText', 
      target: '//body', 
      value: '*Fatal error:*' 
     }); 

     return commands; 
    } 
}); 

希望有所幫助。