Selenium TestRunnerとCore拡張


Selenium Test Runner
大量のSuiteファイルとTestファイルを作成し、大規模なテスト実行を行う場合、Selenium IDEを採用するのはあまり便利ではありません.これはSelenium Test Runnerモードを採用することができます.
更にSelenium IDEツールバーでクリック(play with selenium testrunnner)してSelenium Test Runnerに入ります
アドレスバーを見ると、いくつかのパラメータがあります.
chrome://selenium-ide-testrunner/content/selenium/TestRunner.html?test=/content/PlayerTestSuite.html&userExtensionsURL=&baseUrl=

test:再ローカルまたはサーバに格納するSuiteファイルを指定し、ローカルファイルはfile://プロトコルで開くことができ、サーバ上のhttpプロトコルで開くことができます.
userExtensionsURL
baseUrl:URLアドレスに対してwww.google.cn後、openコマンド'/'、開いているのはwww.google.cnページ.
selenium_suite.htmlファイル
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://cn.calendar.yahoo.com/" />
<title>selenium_1</title>
</head>
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium"> 
<tbody>
<tr><td><b>Example one</b></td></tr>
<tr><td><b><a href="/home/xace/coding/selenium_case1.html">test case1</a></b></td></tr>
</tbody></table>
</body>
</html>

selenium_case1.htmlファイル
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://cn.calendar.yahoo.com/" />
<title>selenium_case1</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">selenium_case1</td></tr>
</thead><tbody>
<tr>
	<td>open</td>
	<td>/</td>
	<td></td>
</tr>
<tr>
	<td>type</td>
	<td>username</td>
	<td>zhangyc.beijing</td>
</tr>
<tr>
	<td>type</td>
	<td>passwd</td>
	<td> </td>
</tr>
<tr>
	<td>clickAndWait</td>
	<td>//input[@value=' ']</td>
	<td></td>
</tr>
<tr>
	<td>verifyTextPresent</td>
	<td>[ ,  ]</td>
	<td></td>
</tr>

</tbody></table>
</body>
</html>

urlアドレス:
chrome://selenium-ide-testrunner/content/selenium/TestRunner.html?test=file:///home/xace/coding/selenium_suite.html&userExtensionsURL=,&baseUrl=http://cn.calendar.yahoo.com

再selenium/selenium-core/testsディレクトリには、より多くの例があります.
chrome://selenium-ide-testrunner/content/selenium/TestRunner.html?test=file://xxx/selenium/selenium-core/tests/TestSuite.html&userExtensionsURL=,&baseUrl=

/home/xace/.mozilla/firefox/tmug0k1u.default/extensions/{a6fd85ed-e919-4a43-a5af-8da18bda539f}
chrome://selenium-ide-testrunner/content/selenium/TestRunner.html
Selenium Coreの拡張とその応用
実際の応用では,selenium coreが提供するコマンドが深層的なニーズを完全に満たすことができないことが分かった.各社の業務と製品には多かれ少なかれ違いがあり、ほとんどの外部のテストツールは深層的なテストニーズを完全に満たすことができず、seleniumは良い拡張メカニズムを提供して役に立ちます.
Seleniunの基本メカニズム
1コアコードはどこですか?
Selenium coreはjarパッケージで、/home/{user}/.mozilla/firefox/xxxxxxx.default/extensions/{a6fd85ed-e919-4a43-a5af-8da18bda539f} ; C:\Documents and Settings\{user}\Application Data\Mozilla\Firefox\Profiles\xxxxxxx.default\extensions\{a6fd85ed-e919-4a43-a5af-8da18bda539f}.{user}は現在のシステムユーザー、xxxxxです.dufaultはシーケンスです.
rarでselenium-ideを解凍する.jar、contentsseleniumscriptディレクトリの下にファイルselenium-apiを見つけることができます.js,我々が以前使っていたコマンド(click select checkなど)はここにあり,キーワードdoClick doSelect doCheckに対応している.
2コード分析
doの先頭のネーミング方式は、APIがアクションコマンドであることを示す.
Selenium.prototype.doClick = function(locator) {
    //  DOM , id name xpath document 
    var element = this.browserbot.findElement(locator);
    //  DOM 
    this.browserbot.clickElement(element);
};

browserbotの方法はselenium-browserbot.js中
3 seleniumコマンドの拡張
アクションコマンドAPI
  selenium-api.js 
Selenium.prototype.doHello = function() {
    throw new SeleniumError("hello");
    //  hello , 3 hello, 
};
 
<tr>
	<td>hello</td>
	<td></td>
	<td></td>
</tr>

アサーションコマンドAPI
Selenium.prototype.isHello = function(text) {
    var originalText = "hello";
    if(originalText == text){
        return true;
    }
    return false;
};
 
<tr>
	<td>verifyHello</td>
	<td>hello</td>
	<td></td>
</tr>
<tr>
	<td>verifyHello</td>
	<td>hi is not hello</td>
	<td></td>
</tr>

Selenium.prototype.getHello = function(text) {
    return "hello";
};
 
<tr>
	<td>verifyHello</td>
	<td></td>
	<td>hello</td>
</tr>
<tr>
	<td>verifyHello</td>
	<td></td>
	<td>hi is not hello</td>
</tr>