f2etest-recorder
Advanced tools
Comparing version 0.9.34 to 0.9.35
var initConfig = require('./lib/init.js'); | ||
var startRecorder = require('./lib/start.js'); | ||
var checkUpdate = require('./lib/update.js'); | ||
module.exports = { | ||
init: initConfig, | ||
start: startRecorder, | ||
checkUpdate: checkUpdate | ||
start: startRecorder | ||
}; |
165
lib/start.js
@@ -12,2 +12,3 @@ var path = require('path'); | ||
var expect = require('expect.js'); | ||
var faker = require('faker'); | ||
var WebSocketServer = require('websocket').server; | ||
@@ -148,3 +149,3 @@ require('colors'); | ||
lastFrameId = null; | ||
pushTestCode('switchWindow', '', window, 'yield browser.switchWindow('+window+');') | ||
pushTestCode('switchWindow', '', window, 'yield browser.sleep(500).switchWindow('+window+');') | ||
checkerBrowser && checkerBrowser.switchWindow(window).then(doNext).catch(catchError) || callback(); | ||
@@ -176,8 +177,10 @@ } | ||
if(frame !== null){ | ||
arrCodes.push('yield browser.wait("'+frame+'", 30000).switchFrame("'+frame+'").wait("body");'); | ||
arrCodes.push('var element = yield browser.wait(\''+frame+'\', 30000);'); | ||
arrCodes.push('yield browser.switchFrame(element).wait(\'body\');'); | ||
} | ||
pushTestCode('switchFrame', '', frame, arrCodes); | ||
checkerBrowser && checkerBrowser.switchFrame(null, function(error){ | ||
checkerBrowser && checkerBrowser.switchFrame(null, function*(error){ | ||
if(frame !== null){ | ||
return checkerBrowser.wait(frame, 10000).switchFrame(frame).wait('body'); | ||
var element = yield checkerBrowser.wait(frame, 10000); | ||
yield checkerBrowser.switchFrame(element).wait('body'); | ||
} | ||
@@ -220,45 +223,64 @@ }).then(doNext).catch(catchError) || doNext(); | ||
break; | ||
case 'wait': | ||
arrCodes = []; | ||
arrCodes.push('var element = yield browser.wait(\''+data.path+'\', 30000);'); | ||
arrCodes.push('expect(element.length).to.be(1);'); | ||
pushTestCode('wait', '', data.path, arrCodes); | ||
checkerBrowser && checkerBrowser.wait(data.path, 10000).then(function(element){ | ||
expect(element.length).to.be(1); | ||
}).then(doNext).catch(catchError) || doNext(); | ||
case 'waitBody': | ||
pushTestCode('waitBody', '', '', 'yield browser.sleep(500).wait(\'body\', 30000);'); | ||
checkerBrowser && checkerBrowser.sleep(500).wait('body', 10000).then(doNext).catch(catchError) || doNext(); | ||
break; | ||
case 'target': | ||
case 'mouseMove': | ||
arrCodes = []; | ||
arrCodes.push('var element = yield browser.wait(\''+data.path+'\', 30000);'); | ||
arrCodes.push('expect(element.length).to.be(1);'); | ||
arrCodes.push('yield browser.sleep(300).mouseMove(\''+data.path+'\');'); | ||
pushTestCode('target', data.text, data.path, arrCodes); | ||
checkerBrowser && checkerBrowser.wait(data.path, 10000).then(function(element){ | ||
expect(element.length).to.be(1); | ||
}).mouseMove(data.path).then(doNext).catch(catchError) || doNext(); | ||
break; | ||
case 'mouseMove': | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+data.path+'\', 30000);'); | ||
if(data.x !== undefined){ | ||
pushTestCode('mouseMove', data.text, data.path+', '+data.x+', '+data.y, 'yield browser.mouseMove(\''+data.path+'\', '+data.x+', '+data.y+');'); | ||
arrCodes.push('yield browser.sleep(300).mouseMove(element, '+data.x+', '+data.y+');'); | ||
} | ||
else{ | ||
pushTestCode('mouseMove', data.text, data.path, 'yield browser.mouseMove(\''+data.path+'\');'); | ||
arrCodes.push('yield browser.sleep(300).mouseMove(element);'); | ||
} | ||
checkerBrowser && checkerBrowser.mouseMove(data.path, data.x, data.y).then(doNext).catch(catchError) || doNext(); | ||
pushTestCode('mouseMove', data.text, data.path+(data.x !== undefined?', '+data.x+', '+data.y:''), arrCodes); | ||
checkerBrowser && checkerBrowser.sleep(300).wait(data.path, 10000).then(function*(element){ | ||
yield checkerBrowser.sleep(300).mouseMove(element, data.x, data.y); | ||
}).then(doNext).catch(catchError) || doNext(); | ||
break; | ||
case 'mouseDown': | ||
pushTestCode('mouseDown', data.text, data.path + ', ' + data.x + ', ' + data.y + ', ' + data.button, 'yield browser.mouseMove(\''+data.path+'\', '+data.x+', '+data.y+').mouseDown('+data.button+');'); | ||
checkerBrowser && checkerBrowser.mouseMove(data.path, data.x, data.y).mouseDown(data.button).then(doNext).catch(catchError) || doNext(); | ||
arrCodes = []; | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+data.path+'\', 30000);'); | ||
arrCodes.push('yield browser.sleep(300).mouseMove(element, '+data.x+', '+data.y+').mouseDown('+data.button+');'); | ||
pushTestCode('mouseDown', data.text, data.path + ', ' + data.x + ', ' + data.y + ', ' + data.button, arrCodes); | ||
checkerBrowser && checkerBrowser.sleep(300).wait(data.path, 10000).then(function*(element){ | ||
yield checkerBrowser.sleep(300).mouseMove(element, data.x, data.y).mouseDown(data.button); | ||
}).then(doNext).catch(catchError) || doNext(); | ||
break; | ||
case 'mouseUp': | ||
pushTestCode('mouseUp', data.text, data.path + ', ' + data.x + ', ' + data.y + ', ' + data.button, 'yield browser.mouseMove(\''+data.path+'\', '+data.x+', '+data.y+').mouseUp('+data.button+');'); | ||
checkerBrowser && checkerBrowser.mouseMove(data.path, data.x, data.y).mouseUp(data.button).then(doNext).catch(catchError) || doNext(); | ||
arrCodes = []; | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+data.path+'\', 30000);'); | ||
arrCodes.push('yield browser.sleep(300).mouseMove(element, '+data.x+', '+data.y+').mouseUp('+data.button+');'); | ||
pushTestCode('mouseUp', data.text, data.path + ', ' + data.x + ', ' + data.y + ', ' + data.button, arrCodes); | ||
checkerBrowser && checkerBrowser.sleep(300).wait(data.path, 10000).then(function*(element){ | ||
yield checkerBrowser.sleep(300).mouseMove(element, data.x, data.y).mouseUp(data.button); | ||
}).then(doNext).catch(catchError) || doNext(); | ||
break; | ||
case 'click': | ||
pushTestCode('click', data.text, data.path + ', ' + data.x + ', ' + data.y + ', ' + data.button, 'yield browser.mouseMove(\''+data.path+'\', '+data.x+', '+data.y+').click('+data.button+');'); | ||
checkerBrowser && checkerBrowser.mouseMove(data.path, data.x, data.y).click(data.button).then(doNext).catch(catchError) || doNext(); | ||
arrCodes = []; | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+data.path+'\', 30000);'); | ||
arrCodes.push('yield browser.sleep(300).mouseMove(element, '+data.x+', '+data.y+').click('+data.button+');'); | ||
pushTestCode('click', data.text, data.path + ', ' + data.x + ', ' + data.y + ', ' + data.button, arrCodes); | ||
checkerBrowser && checkerBrowser.sleep(300).wait(data.path, 10000).then(function*(element){ | ||
yield checkerBrowser.sleep(300).mouseMove(element, data.x, data.y).click(data.button); | ||
}).then(doNext).catch(catchError) || doNext(); | ||
break; | ||
case 'touchClick': | ||
arrCodes = []; | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+data.path+'\', 30000);'); | ||
arrCodes.push('yield element.sleep(300).touchClick();'); | ||
pushTestCode('touchClick', data.text, data.path, arrCodes); | ||
checkerBrowser && checkerBrowser.sleep(300).wait(data.path, 10000).then(function*(element){ | ||
yield element.sleep(300).touchClick(); | ||
}).then(doNext).catch(catchError) || doNext(); | ||
break; | ||
case 'dblClick': | ||
pushTestCode('dblClick', data.text, data.path + ', ' + data.x + ', ' + data.y, 'yield browser.mouseMove(\''+data.path+'\', '+data.x+', '+data.y+').click().click();'); | ||
checkerBrowser && checkerBrowser.mouseMove(data.path, data.x, data.y).click().click().then(doNext).catch(catchError) || doNext(); | ||
arrCodes = []; | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+data.path+'\', 30000);'); | ||
arrCodes.push('yield browser.sleep(300).mouseMove(element, '+data.x+', '+data.y+').click().click();'); | ||
pushTestCode('dblClick', data.text, data.path + ', ' + data.x + ', ' + data.y + ', ' + data.button, arrCodes); | ||
checkerBrowser && checkerBrowser.sleep(300).wait(data.path, 10000).then(function*(element){ | ||
yield checkerBrowser.sleep(300).mouseMove(element, data.x, data.y).click().click(); | ||
}).then(doNext).catch(catchError) || doNext(); | ||
break; | ||
@@ -283,11 +305,10 @@ case 'sendKeys': | ||
arrCodes = []; | ||
arrCodes.push('yield browser.wait(\''+data.path+'\', 30000).then(function(element){'); | ||
arrCodes.push(' return element.select({'); | ||
arrCodes.push(' type: "'+data.type+'",'); | ||
arrCodes.push(' value: "'+data.value+'"'); | ||
arrCodes.push(' });'); | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+data.path+'\', 30000);'); | ||
arrCodes.push('yield element.sleep(300).select({'); | ||
arrCodes.push(' type: \''+data.type+'\','); | ||
arrCodes.push(' value: \''+data.value+'\''); | ||
arrCodes.push('});'); | ||
pushTestCode('select', data.text, data.path + ', ' + data.type + ', ' + data.value, arrCodes); | ||
checkerBrowser && checkerBrowser.wait(data.path, 10000).then(function(element){ | ||
return element.select({ | ||
checkerBrowser && checkerBrowser.sleep(300).wait(data.path, 10000).then(function*(element){ | ||
yield element.sleep(300).select({ | ||
type: data.type, | ||
@@ -312,13 +333,10 @@ value: data.value | ||
arrCodes = []; | ||
arrCodes.push('yield browser.wait(\''+data.path+'\', {timeout: 30000, displayed: false}).then(function*(element){'); | ||
arrCodes.push(' yield element.sendKeys("c:\\\\uploadFiles\\\\'+data.filename+'");'); | ||
arrCodes.push('});'); | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+data.path+'\', {timeout: 30000, displayed: false});'); | ||
arrCodes.push('yield element.sleep(300).sendKeys(\'c:\\\\uploadFiles\\\\'+data.filename+'\');'); | ||
pushTestCode('uploadFile', data.text, data.path + ', ' + data.filename, arrCodes); | ||
checkerBrowser && checkerBrowser.wait(data.path, { | ||
checkerBrowser && checkerBrowser.sleep(300).wait(data.path, { | ||
timeout: 10000, | ||
displayed: false | ||
}, function*(error, element){ | ||
if(!error){ | ||
yield element.sendKeys('c:\\uploadFiles\\'+data.filename); | ||
} | ||
}).then(function*(element){ | ||
yield element.sleep(300).sendKeys('c:\\uploadFiles\\'+data.filename); | ||
}).then(doNext).catch(catchError) || doNext(); | ||
@@ -337,4 +355,3 @@ break; | ||
if(reDomRequire.test(expectType)){ | ||
arrCodes.push('var element = yield browser.wait("'+expectParams[0]+'", 30000);'); | ||
arrCodes.push('expect(element.length).to.be(1);'); | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+expectParams[0]+'\', 30000);'); | ||
} | ||
@@ -358,6 +375,6 @@ switch(expectType){ | ||
case 'attr': | ||
arrCodes.push('var value = yield element.attr("'+expectParams[1]+'");'); | ||
arrCodes.push('var value = yield element.attr(\''+expectParams[1]+'\');'); | ||
break; | ||
case 'css': | ||
arrCodes.push('var value = yield element.css("'+expectParams[1]+'");'); | ||
arrCodes.push('var value = yield element.css(\''+expectParams[1]+'\');'); | ||
break; | ||
@@ -371,9 +388,9 @@ case 'url': | ||
case 'cookie': | ||
arrCodes.push('var value = yield browser.cookie("'+expectParams[0]+'");'); | ||
arrCodes.push('var value = yield browser.cookie(\''+expectParams[0]+'\');'); | ||
break; | ||
case 'localStorage': | ||
arrCodes.push('var value = yield browser.localStorage("'+expectParams[0]+'");'); | ||
arrCodes.push('var value = yield browser.localStorage(\''+expectParams[0]+'\');'); | ||
break; | ||
case 'sessionStorage': | ||
arrCodes.push('var value = yield browser.sessionStorage("'+expectParams[0]+'");'); | ||
arrCodes.push('var value = yield browser.sessionStorage(\''+expectParams[0]+'\');'); | ||
break; | ||
@@ -384,6 +401,6 @@ } | ||
case 'equal': | ||
arrCodes.push('expect(value).to.equal('+(/^(true|false)$/.test(codeExpectTo)?codeExpectTo:'"'+codeExpectTo+'"')+');'); | ||
arrCodes.push('expect(value).to.equal('+(/^(true|false)$/.test(codeExpectTo)?codeExpectTo:'\''+codeExpectTo+'\'')+');'); | ||
break; | ||
case 'contain': | ||
arrCodes.push('expect(value).to.contain("'+codeExpectTo+'");'); | ||
arrCodes.push('expect(value).to.contain(\''+codeExpectTo+'\');'); | ||
break; | ||
@@ -398,4 +415,3 @@ case 'regexp': | ||
if(reDomRequire.test(expectType)){ | ||
element = yield checkerBrowser.wait(expectParams[0], 10000); | ||
expect(element.length).to.be(1); | ||
element = yield checkerBrowser.sleep(300).wait(expectParams[0], 10000); | ||
} | ||
@@ -456,9 +472,24 @@ switch(expectType){ | ||
// 设置变量 | ||
case 'setvar': | ||
case 'setVar': | ||
var varinfo = data.varinfo; | ||
var varType = varinfo.type; | ||
arrCodes = []; | ||
arrCodes.push('var element = yield browser.wait(\''+data.path+'\', 30000);'); | ||
arrCodes.push('yield element.val(testVars["'+data.name+'"]);'); | ||
pushTestCode('setvar', data.text, data.path + ', ' + data.name, arrCodes); | ||
checkerBrowser && checkerBrowser.wait(data.path, 10000, function(error, element){ | ||
return element.val(testVars[data.name]); | ||
arrCodes.push('var element = yield browser.sleep(300).wait(\''+data.path+'\', 30000);'); | ||
if(varType ==='faker'){ | ||
arrCodes.push('faker.locale = \'' + varinfo.lang + '\';'); | ||
arrCodes.push('yield element.val(faker.fake(\''+varinfo.str+'\'));'); | ||
pushTestCode('setFaker', data.text, data.path + ', ' + varinfo.lang + ', ' + varinfo.str, arrCodes); | ||
} | ||
else{ | ||
arrCodes.push('yield element.val(testVars[\''+varinfo.name+'\']);'); | ||
pushTestCode('setVar', data.text, data.path + ', ' + varinfo.name, arrCodes); | ||
} | ||
checkerBrowser && checkerBrowser.sleep(300).wait(data.path, 10000).then(function*(element){ | ||
if(varType === 'faker'){ | ||
faker.locale = varinfo.lang; | ||
yield element.val(faker.fake(varinfo.str)); | ||
} | ||
else{ | ||
yield element.val(testVars[varinfo.name]); | ||
} | ||
}).then(doNext).catch(catchError) || doNext(); | ||
@@ -478,3 +509,3 @@ break; | ||
recorderBrowser = browser; | ||
yield browser.url('chrome-extension://njkfhfdkecbpjlnfmminhmdcakopmcnc/start.html'); | ||
yield browser.url('chrome-extension://njkfhfdkecbpjlnfmminhmdcakopmcnc/start.html');// pjnogcehfcicpmolniddckcagldcfjcl | ||
var browerInfo = yield recorderBrowser.info(); | ||
@@ -741,3 +772,3 @@ var browserId = browerInfo['f2etest.browserId']; | ||
capabilities.chromeOptions = { | ||
// args:['disable-bundled-ppapi-flash', 'load-extension=E:\\github\\f2etest\\f2etest-recorder\\chrome-extension'], | ||
// args:['disable-bundled-ppapi-flash', 'load-extension=E:\\github\\f2etest\\f2etest-recorder\\chrome-extension'] | ||
args: ['disable-bundled-ppapi-flash'], | ||
@@ -744,0 +775,0 @@ extensions: [extContent] |
{ | ||
"name": "f2etest-recorder", | ||
"version": "0.9.34", | ||
"version": "0.9.35", | ||
"description": "Nodejs client for f2etest-recorder", | ||
@@ -15,4 +15,5 @@ "main": "./index", | ||
"expect.js": "0.3.1", | ||
"faker": "3.1.0", | ||
"inquirer": "1.0.2", | ||
"jwebdriver": "1.0.9", | ||
"jwebdriver": "1.0.12", | ||
"websocket": "1.0.22" | ||
@@ -19,0 +20,0 @@ }, |
@@ -27,3 +27,3 @@ f2etest-recorder | ||
> npm install jwebdriver expect.js mocha-generators --save-dev | ||
> npm install jwebdriver expect.js mocha-generators faker --save-dev | ||
@@ -65,3 +65,4 @@ > mocha test.spec.js | ||
* inquirer: [https://github.com/sboudrias/Inquirer.js](https://github.com/sboudrias/Inquirer.js) | ||
* jwebdriver: [https://github.com/yaniswang/jWebDriver](https://github.com/yaniswang/jWebDriver) | ||
* jWebDriver: [https://github.com/yaniswang/jWebDriver](https://github.com/yaniswang/jWebDriver) | ||
* async: [https://github.com/caolan/async](https://github.com/caolan/async) | ||
* Faker.js: [https://github.com/marak/Faker.js/](https://github.com/marak/Faker.js/) |
var JWebDriver = require('jwebdriver'); | ||
var expect = require("expect.js"); | ||
var expect = require('expect.js'); | ||
require('mocha-generators').install(); | ||
var fs = require('fs'); | ||
var faker = require('faker'); | ||
@@ -6,0 +7,0 @@ // read config |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
366540
67
6
9
11
950
+ Addedfaker@3.1.0
+ Addedfaker@3.1.0(transitive)
+ Addedjwebdriver@1.0.12(transitive)
- Removedjwebdriver@1.0.9(transitive)
Updatedjwebdriver@1.0.12