Professional Documents
Culture Documents
(1)ProtractorEnhanceTroubleShooting
FiniganJoyce
ProtractorEnhanceTroubleShooting
PaulLi
20152619:25
YahooFrontEndEngineer
PaulLi
RSS
protractor
Protractorendtoendtestframework.endtoendtest?!
userbrowser(100%),flow?
JavaScriptmodule?,
TroubleShooting,,Protractorerror,
errormessage,,
,,
,!!
19,619
10,000
error
,Protractor,,
,error
UPUPUP
10,000
NoSuchElementError:Noelementfoundusinglocator:By.cssSelector(".logo2")
!!
https://www.facebook.com/notes/paulli/protractorenhance%E7%AF%87troubleshooting/10152956325467211
1/6
2016/1/13
(1)ProtractorEnhanceTroubleShooting
className.logo2element,fail
UnknownError:unknownerror:Elementisnotclickableatpoint(332,712).Other
elementwouldreceivetheclick:<divclass="formfieldinputshippingwrap">...<
/div>
,elementdisable
JavaScript,,
errormessageTroubleShooting,
errormessage,,test
code
,testcode,
testcode
error
ProtractorAPIthenable,error,
then,thenCatch
$('button').click().then(
function(){
//dosomething
...
...
}
).then(
function(){
$('.logo').click().then(
function(){
//dosomething
...
...
}
)
}
).thenCatch(
function(err){
//errorhappen
console.log('errorhappen')
callback.fail()
}
).then(callback,callback)
,thenCatch,
error,,
console.log!
,then,then
dataformat
https://www.facebook.com/notes/paulli/protractorenhance%E7%AF%87troubleshooting/10152956325467211
2/6
2016/1/13
(1)ProtractorEnhanceTroubleShooting
$('.infomation').getText().then(
function(text){
returnNumber(text)
},
function(){
return0
}
).then(
function(amount){
expect(amount).to.be.at.least(100)
}
).then(callback,callback)
,*[class~=information]element,default
dataformat,texterror,then
amount=0,step,Protractor
errortesthang
error,ScreenShot
errormessage,,
ScreenShot,,
Cucumberhook
varstepResultHooks=function(){
varfs=require('fs'),dir='/screenShots/'
this.StepResult(function(event,callBack){
varstepResult=event.getPayloadItem('stepResult'),
step=stepResult.getStep()
if(stepResult.isFailed()){
browser.takeScreenshot().then(function(png){
varstream,fname
fname='err_'+step.getLine()+'_'+step.getName()+'_'
fname+=newDate().getTime()+'.png'
fname=fname.replace(/"|'|\//g,'').replace(/\s|:|>/g,'_')
stream=fs.createWriteStream(dir+fname)
stream.write(newBuffer(png,'base64'))
stream.end()
}).then(callBack)
}elsecallBack()
})
}
module.exports=stepResultHooks
git:https://github.com/meistudioli/protractorEx/blob/master/cucumber/support/stepResult
Hooks.js
hook,steperror,method
ProtractortakeScreenshot,filename
stepinfomation,ScreenShotstep!
...,
pattern,bug,worksformeresponse,
,bug!
https://www.facebook.com/notes/paulli/protractorenhance%E7%AF%87troubleshooting/10152956325467211
3/6
2016/1/13
(1)ProtractorEnhanceTroubleShooting
Login
https://www.facebook.com/notes/paulli/protractorenhance%E7%AF%87troubleshooting/10152956325467211
4/6
2016/1/13
(1)ProtractorEnhanceTroubleShooting
ScreenShot,Protractor,
error!
,element
element,liclick,
Firefoxfail,lielement,
protractor$(element).click(),,
PS.elementcursorelement,
<a>,<button>,<inputtype="submit">
,viewportelement,,
elementviewport,scroll
elementbrowser.actions().mouseMove(element)
browserelement
debug,70%,
,30%!
troubleshooting,,Protractor
!
:
Protractor:https://www.facebook.com/notes/paulli/protractor
%E7%92%B0%E5%A2%83%E8%A8%AD%E5%AE%9A%E7%AF%87/101529486
08982211
ProtractorConfigFile:https://www.facebook.com/notes/paulli/protractor
%E5%AF%A6%E6%88%B0%E7%AF%87configfile/10152950568012211
ProtractorPageObjects:https://www.facebook.com/notes/paul
li/protractorpageobjects/10152952559442211
Protractorthelastpuzzlepiece:https://www.facebook.com/notes/paul
li/protractor%E5%AF%A6%E6%88%B0%E7%AF%87thelastpuzzle
piece/10153403944567211
ProtractorEnhanceRunScenario(s)in
serial:https://www.facebook.com/notes/paulli/protractorenhance%E7%AF%87
runscenariosinserial/10152962969242211
ProtractorEnhanceRunSuite(s)in
serial:https://www.facebook.com/notes/paulli/protractorenhance%E7%AF%87
runsuitesinserial/10152966936232211
ProtractorEnhanceConvertfeaturesto
document:https://www.facebook.com/notes/10153169915752211/?pnref=story
38
1
Cookie
Facebook2016
()
https://www.facebook.com/notes/paulli/protractorenhance%E7%AF%87troubleshooting/10152956325467211
5/6
2016/1/13
(1)ProtractorEnhanceTroubleShooting
https://www.facebook.com/notes/paulli/protractorenhance%E7%AF%87troubleshooting/10152956325467211
6/6