I try to make simple app ..try to test using protractor ? I install every thing .and able to run protractor given example ..than I make my own example like this
我尝试使用量角器进行简单的app ..try测试?我安装了所有的东西。并且能够运行量角器给出的例子..我自己做这样的例子
Index.html ..
Index.html ..
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Super</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>
<script src="app.js"></script>
</head>
<body ng-app ="app">
<div ui-view></div>
</body>
</html>
app.js
app.js
angular.module('app',['ui.router']).config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise("/state1");
//
// Now set up the states
$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "partial/state1.html" ,
controller:function($scope){
$scope.clikme=function(){
$scope.message="hello"
}
}
})
})
example.spec.js
example.spec.js
var indexFunction=require('/indexFunction');
describe('angularjs homepage', function() {
var page =new indexFunction();
beforeEach(function(){
page.getUrl()
})
it('should greet the named user', function() {
expect(page.getTitile()).toEqual('Super');
});
it('should update',function(){
page.clickMethod();
expect(page.getMessage()).toBe('hello')
})
});
index.spec.js
index.spec.js
function indexFunction(){
this.button= element(by.id('clickme')) ;
this.message=element(by.binding('message')) ;
this.getUrl=function(){
browser.get('http://localhost:63342/example/index.html');
}
this.getTitile=function(){
return browser.getTitle();
}
this.getMessage=function(){
return this.message.getText();
}
this.clickMethod=function(){
this.button.click();
}
}
module.exports=indexFunction
when I run this example I got this error
当我运行这个例子时,我收到了这个错误
[![MacBook-Pro:example naveenkumar$ protractor conf.js
Using ChromeDriver directly...
\[launcher\] Running 1 instances of WebDriver
\[launcher\] Error: Error: Cannot find module '/indexFunction'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/naveenkumar/Desktop/example/example_spec.js:2:23)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:][1]][1]
Update
更新
r: Error: Cannot find module '/index.spec'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
1 个解决方案
#1
1
In example.spec.js
it should be:
在example.spec.js中它应该是:
var indexFunction = require('./index.spec');
#1
1
In example.spec.js
it should be:
在example.spec.js中它应该是:
var indexFunction = require('./index.spec');