//Jsobjectdemo.js:
function car() {
this.firstinput=element(by.model("first"));
this.secondinput=element(by.model("second"));
this.goButton=element(by.id("gobutton"));
this.result=element(by.css("h2[class='ng-binding']"));
this.color="red"; this.engine="turbo"; this.brand="BMW";
this.search="by.css('input')";
this.getURL=function() {
browser.get('http://juliemr.github.io/protractor-demo/'); };
};
module.exports= new car();
//JsAccess.js:
```var obj= require("./Jsobjectdemo.js");
obj.getModel();
console.log(obj.search);
//Jsobjectdemo
const car = {
firstinput :element(by.model("first")),
secondinput : element(by.model("second")),
goButton : element(by.id("gobutton")),
result : element(by.css("h2[class='ng-binding']")),
color : "red", engine : "turbo", brand : "BMW",
search : "by.css('input')",
getURL : function () {
browser.get('http://juliemr.github.io/protractor-demo/')
}
}
exports.car = car;
//JsAccess.js:
const {car} = require(`./Jsobjectdemo`)
console.log(car.search)
注意:element和by必须从pages文件
中的protractor中导入const {by, element, browser} = require('protractor');