如何在量角器中调用另一个函数中的函数
How to call a function in another function in protractor
第一个函数
describe('Shortlisting page', function () {
it('Click on candidate status Screened', function () {
element(by.css('i.flaticon-leftarrow48')).click();
browser.sleep(5000);
browser.executeScript('window.scrollTo(0,250);');
element(by.partialButtonText('Initial Status')).click();
browser.sleep(2000);
var screen = element.all(by.css('[ng-click="setStatus(choice, member)"]')).get(1);
screen.click();
element(by.css('button.btn.btn-main.btn-sm')).click();
browser.executeScript('window.scrollTo(250,0);');
browser.sleep(5000);
});
})
第二个函数
it('Click on candidate status Screened', function () {
//Here i need to call first function
});
我想在"second function"中给"first function"打电话,请问怎么打
您作为第一个函数编写的内容不是您可以调用或调用的东西。 describe
是一个全局 Jasmine 函数,用于以 explanatory/human 可读的方式对测试规范进行分组以创建测试套件。您必须编写一个函数来在您的测试规范或 it
中调用它。这是一个例子 -
//Write your function in the same file where test specs reside
function clickCandidate(){
element(by.css('i.flaticon-leftarrow48')).click();
//All your code that you want to include that you want to call from test spec
};
在您的测试规范中调用上面定义的函数 -
it('Click on candidate status Screened', function () {
//Call the first function
clickCandidate();
});
您也可以在页面对象文件中编写此函数,然后从您的测试规范中调用它。这是一个例子 -
//Page object file - newPage.js
newPage = function(){
function clickCandidate(){
//All your code that you want to call from the test spec
});
};
module.exports = new newPage();
//Test Spec file - test.js
var newPage = require('./newPage.js'); //Write the location of your javascript file
it('Click on candidate status Screened', function () {
//Call the function
newPage.clickCandidate();
});
希望对您有所帮助。
第一个函数
describe('Shortlisting page', function () {
it('Click on candidate status Screened', function () {
element(by.css('i.flaticon-leftarrow48')).click();
browser.sleep(5000);
browser.executeScript('window.scrollTo(0,250);');
element(by.partialButtonText('Initial Status')).click();
browser.sleep(2000);
var screen = element.all(by.css('[ng-click="setStatus(choice, member)"]')).get(1);
screen.click();
element(by.css('button.btn.btn-main.btn-sm')).click();
browser.executeScript('window.scrollTo(250,0);');
browser.sleep(5000);
});
})
第二个函数
it('Click on candidate status Screened', function () {
//Here i need to call first function
});
我想在"second function"中给"first function"打电话,请问怎么打
您作为第一个函数编写的内容不是您可以调用或调用的东西。 describe
是一个全局 Jasmine 函数,用于以 explanatory/human 可读的方式对测试规范进行分组以创建测试套件。您必须编写一个函数来在您的测试规范或 it
中调用它。这是一个例子 -
//Write your function in the same file where test specs reside
function clickCandidate(){
element(by.css('i.flaticon-leftarrow48')).click();
//All your code that you want to include that you want to call from test spec
};
在您的测试规范中调用上面定义的函数 -
it('Click on candidate status Screened', function () {
//Call the first function
clickCandidate();
});
您也可以在页面对象文件中编写此函数,然后从您的测试规范中调用它。这是一个例子 -
//Page object file - newPage.js
newPage = function(){
function clickCandidate(){
//All your code that you want to call from the test spec
});
};
module.exports = new newPage();
//Test Spec file - test.js
var newPage = require('./newPage.js'); //Write the location of your javascript file
it('Click on candidate status Screened', function () {
//Call the function
newPage.clickCandidate();
});
希望对您有所帮助。