Firefox 3.6.3にて動作確認。(2010/04/16, Selenium IDE 1.0.6)
{
'BaseURL': 'file:///D:/_temp/NumberString.html',
'PageTitle': 'NumberString',
'input1': '123456789',
'output1': '一二三四五六七八九',
'input2': '999999',
'output2': '九九九九九九',
'input3': '987654321',
'output3': '九八七六五四三二一'
}
// ローカルファイルの読み書き
// Firefox専用
// http://cyprus.ex.nii.ac.jp/~kameda/blog/KMKM/KMKM0711030805.htm
// modified by TakeAsh, 2010/04/16
function readFromFile( filePath ){
var data = "";
try {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(filePath);
var fInStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
fInStream.init(file, -1, 0, 0);
var charset = "UTF-8";
const replacementChar = Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER;
var cvtInStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].createInstance(Components.interfaces.nsIConverterInputStream);
cvtInStream.init(fInStream, charset, 1024, replacementChar);
var str = {};
while ( cvtInStream.readString(4096, str) ){
data += str.value;
}
cvtInStream.close();
} catch(e){
throw e;
}
return data;
}
function writeToFile( filePath, content, append ){
try {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(filePath);
if (!file.exists()){
file.create(0, 0666);
}
var fOutStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
// https://developer.mozilla.org/ja/Code_snippets/File_I//O
// 0x02:PR_WRONLY 0x10:PR_APPEND 0x20:PR_TRUNCATE
var flag = 0x02 | ( (append) ? 0x10 : 0x20);
fOutStream.init(file, flag, 0666, null);
var charset = "UTF-8";
var cvtOutStream = Components.classes["\@mozilla.org/intl/converter-output-stream;1"].createInstance(Components.interfaces.nsIConverterOutputStream);
cvtOutStream.init(fOutStream, charset, 0, 0x0000);
cvtOutStream.writeString(content);
cvtOutStream.close();
} catch(e){
throw e;
}
}
// EOF
function isGood( cond ){
return ( cond ) ? 'Good' : 'NG';
}
{
'BaseURL': 'file:///D:/_temp/SeleniumTest.html',
'PageTitle': 'Seleniumテストサンプル',
'JobCondition': [
// Src1 Operation Src2 chkKanji Result
[ 3, '+', 4, 'off', 7, ],
[ 3, '+', 4, 'on', '七', ],
[ 3, '−', 4, 'off', -1, ],
[ 3, '−', 4, 'on', '−一', ],
[ 3, '×', 4, 'off', 12, ],
[ 3, '×', 4, 'on', '一二', ],
[ 3, '÷', 4, 'off', 0.75, ],
[ 3, '÷', 4, 'on', '〇.七五', ],
[ 1, '+', 0, 'off', 1, ],
[ 1, '+', 0, 'on', '一', ],
[ 1, '−', 0, 'off', 1, ],
[ 1, '−', 0, 'on', '一', ],
[ 1, '×', 0, 'off', 0, ],
[ 1, '×', 0, 'on', '〇', ],
[ 1, '÷', 0, 'off', 'Infinity', ],
[ 1, '÷', 0, 'on', '無限大', ],
[ 1, '+', 'a', 'off', 'NaN', ],
[ 1, '+', 'a', 'on', '非数値', ],
],
}
PageTitle: Seleniumテストサンプル
BaseURL: file:///D:/_temp/SeleniumTest.html
TestDate: Tue Apr 27 2010 00:51:25 GMT+0900
Src1 Op Src2 Kanji Correct Actual Result
3 + 4 off 7 7 Good
3 + 4 on 七 七 Good
3 − 4 off -1 -1 Good
3 − 4 on −一 −一 Good
3 × 4 off 12 12 Good
3 × 4 on 一二 一二 Good
3 ÷ 4 off 0.75 0.75 Good
3 ÷ 4 on 〇.七五 〇.七五 Good
1 + 0 off 1 1 Good
1 + 0 on 一 一 Good
1 − 0 off 1 1 Good
1 − 0 on 一 一 Good
1 × 0 off 0 0 Good
1 × 0 on 〇 〇 Good
1 ÷ 0 off Infinity Infinity Good
1 ÷ 0 on 無限大 無限大 Good
1 + a off NaN NaN Good
1 + a on 非数値 非数値 Good