javascript – 无法在量角器2.5.1和jasmine 1.3.1上运行我的测试用例?

我的conf.js:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  capabilities: {
    'browserName': 'firefox'
  },

  onPrepare: function() {
      browser.driver.manage().window().maximize();
      protractor.basePath = __dirname;

  },
  suites : {
  qa:   ['./specs/log_in.js','./specs/create_project_external_roles.js','./specs/create_position_us_roles.js',

 beta:   ['./specs/log_in_beta.js','./specs/create_position.js', './specs/candidate_status.js'],

  },

  jasmineNodeOpts: {
      defaultTimeoutInterval: 3000000,
      allScriptsTimeout: 3000000,
      rootElement: "div",
      showColors: true
  },
  baseUrl: '',
};

直到上周五晚上,这个工作正常.突然间,我收到了这个错误:

Failed: Error while waiting for Protractor to sync with the page: “angular could not be found on the window”.

log_in.js

require(protractor.basePath+'/data/config_values.js');

describe('', function()
{
    it('', function()
    {
        browser.get(url);
        browser.driver.manage().deleteAllCookies();
        browser.ignoreSynchronization = false;
        expect(browser.getTitle())
        element(by.model('username')).sendKeys(user);
        element(by.model('password')).sendKeys(pwd);
        element(by.css('[ng-click="userLogin()"]')).click();
        browser.sleep(5000);
        _current_url_beta = url+'/dash#/'
        expect(browser.getCurrentUrl()).toEqual(_current_url_beta);

    });
});

create_project.js

describe('', function()
{
    it('while clicking create button:', function () {

        element(by.css('span.icon-dir-down')).click();
        browser.sleep(5000);
    });

    it('while clicking create project button:', function() {

        element.all(by.css('[ng-click="openProjectModal($event)"]')).click();
        browser.sleep(5000);
    });
    it('Sending values to project name field', function() {

        element.all(by.model('data.projectName')).sendKeys(external_project_name)
        browser.sleep(5000);
    });

    it('while Clicking domain:', function() {

        element(by.css('a.chosen-single.chosen-default')).click();
        browser.sleep(5000);
    });

    it('Sending values to domain field', function() {

        browser.driver.findElement(By.xpath('//*[@id="Domain_chosen"]/div/div/input')).sendKeys("Information");
        browser.sleep(4000);
    });

    it('selecting domain', function() {

        browser.driver.findElement(By.xpath('//*[@id="Domain_chosen"]/div/ul/li[4]')).click();
        browser.sleep(5000)
    });

    it('while clicking external project button:', function() {

        element.all(by.css('label.btn.btn-default.ng-pristine.ng-untouched.ng-valid')).click();
        browser.sleep(5000);
    });

    it('sending values to external field:', function() {

        browser.driver.findElement(By.xpath('//*[@id="Company"]')).sendKeys("wipro");
        browser.sleep(3000);
    });

    it('selecting external company name', function() {

        element.all(by.css('a.ng-scope.ng-binding')).filter(function (a, index) {
            return index == 0;
        }).each(function (a) {
            a.click();});
        browser.sleep(3000);
    });

    it('Clicking Calender icon:', function(){

        browser.sleep(5000);
        element(by.css('i[ng-click^=open]')).click();
        browser.sleep(3000);
        element(by.css('[ng-click="move(1)"]')).click();
        browser.sleep(4000);
        element(by.css('[ng-click="select(dt.date)"]')).click();
        element(by.css("i[ng-show]")).click();
        element.all(by.css('button.btn.btn-default.btn-sm.pull-right')).filter(function (button, index) {
            return index == 1;
        }).each(function (button) {
            button.click();});
        element.all(by.css('button.btn.btn-default.btn-sm.pull-right')).filter(function (button, index) {
            return index == 1;
        }).each(function (button) {
            button.click();});
        element.all(by.css('button.btn.btn-default.btn-sm.pull-right')).filter(function (button, index) {
            return index == 1;
        }).each(function (button) {
            button.click();
        });
    });

    it('Sending project Description to :',function() {

        browser.sleep(3000);
        browser.driver.findElement
        (By.xpath('/html/body/div[6]/div/div/div/div[2]/div[1]/form/div[3]/div[2]/ul/li/div/table/tbody/tr[3]/td[5]/button')).click();
        element(by.id('Description')).sendKeys(des);
        browser.sleep(3000);
    });

    it('Clicking on create project button  :',function() {

        element(by.css('button.btn.btn-lg.btn-main')).click();
        browser.sleep(5000);

    });

    it('Assertion', function(){

        browser.sleep(5000);
        var newProject = element(by.css('

')); expect(newProject.isPresent()).toEqual(true); browser.sleep(10000); }); });

create_position_us.js

describe('create position for USA', function()
{
    it('while clicking dashboard button:', function () {

        browser.sleep(5000);
        element(by.css('span.icon-stats')).click();
        browser.sleep(3000);
    });


    it('while clicking create button:', function(){
        element(by.css('button.btn.btn-main.dropdown-toggle')).click();
    });

    it('while clicking create position button', function(){
        element(by.css(('[ng-click="openPositionModal($event)"]'))).click();
        browser.sleep(5000);
    });

    it('Sending position values:', function(){
        element(by.model('data.code')).sendKeys(pos_code_us);
        element(by.model('data.title')).sendKeys(pos_title);
        browser.sleep(3000);
        element(by.model('selectedProject')).sendKeys(select_project_name);
        browser.sleep(2000);
        element.all(by.css('a.ng-scope.ng-binding')).filter(function (a, index) {
            return a == 0;}).each(function (button) {
            a.click();})
        browser.sleep(2000);
    });

    it('Clicking Calender icon:', function(){


        element(by.css('a.ng-scope.ng-binding')).click()
        element(by.css('i[ng-click^=open]')).click();
        element(by.css('[ng-click="move(1)"]')).click();
        browser.sleep(1000);
        element(by.css('[ng-click="select(dt.date)"]')).click();
        browser.sleep(2000);
        element.all(by.css('i.icon-date.glyphicon')).click();
        browser.sleep(2000);
        element.all(by.css('button.btn.btn-default.btn-sm.pull-right')).filter(function (button, index) {
            return index == 1;
        }).each(function (button) {
            button.click();
            element.all(by.css('button.btn.btn-default.btn-sm.pull-right')).filter(function (button, index) {
                return index == 1;
            }).each(function (button) {
                button.click();
                element.all(by.css('button.btn.btn-default.btn-sm.pull-right')).filter(function (button, index) {
                    return index == 1;
                }).each(function (button) {
                    button.click();

                });
            });
        });
    });

    it('Sending No.of opening position:', function() {

        browser.sleep(2000);
        browser.driver.findElement
        (By.xpath('/html/body/div[6]/div/div/div/div[2]/div[3]/div[1]/div[1]/form/div[6]/ul/li/div/table/tbody/tr[3]/td[5]/button')).click();
        element(by.model('data.totalOpenings')).sendKeys('10');
        browser.sleep(5000);
    });

    it('Sending salary values:', function() {

        browser.sleep(5000);
        var salary =  element(by.model('data.ctc'));
            salary.isDisplayed().then(function(result) {
                if (result) {
                    salary.sendKeys('500000');
                } else {
                   element(by.model('data.ctc')).sendKeys('500000');
                }
            });
        //element(by.model('data.ctc')).sendKeys('500000');
        browser.sleep(3000);

    });

    it('While Selecting location for US:', function(){
        browser.sleep(3000);
        browser.driver.findElement(By.xpath('/html/body/div[6]/div/div/div/div[2]/div[3]/div[1]/div[1]/form/div[9]/div/div/div/div/input')).sendKeys('los a');
        browser.sleep(3000);
        element.all(by.css('a.ui-select-choices-row-inner')).filter(function (a, index) {
        return index == 0;
        }).each(function (a) {
        a.click();});
    });

    it('Sending position description:', function(){
        element(by.model('data.description')).sendKeys(des);
    });

    it('While clicking analyse skill button:', function(){
        element(by.css('[ng-click="analyzePosition($event)"]')).click();
        browser.sleep(10000);
    });

    it('Sending skill name and selecting the skills:', function() {
        element(by.model('userInput.skillName')).sendKeys('java');
        browser.sleep(1000);
        element.all(by.css("a.ng-scope.ng-binding")).filter(function (a, index) {
            return index == 2;
        }).each(function (a) {
            a.click();
        });
    });

    it('Selecting Percentage:', function() {
        element(by.model('userInput.skillPercent')).sendKeys('80');
        element(by.css('[ng-click="addSkills()"]')).click();
        browser.sleep(1000);
        browser.executeScript('window.scrollTo(250,0);');
        browser.sleep(2000);
    });

    it('Clicking on Preview button:', function(){
        browser.sleep(2000);
        browser.executeScript('window.scrollTo(250,0);');
        browser.sleep(2000);
        element(by.css('button[ng-click="fetchMatches($event)"]')).click();
        browser.sleep(15000);
    });

    it('Selecting Monster:', function() {
        element(by.css('[ng-click="$select.activate()"]')).click();  // Autosource
        browser.sleep(2000);
        element.all(by.css('a.ui-select-choices-row-inner')).filter(function (a, index) {
            return index == 0;
        }).each(function (a) {
            a.click();
        });
    });

    it('Selecting Carrer builder:', function() {
        element(by.css('[ng-click="$select.activate()"]')).click();// Autosource
        browser.sleep(2000);
        element.all(by.css('a.ui-select-choices-row-inner')).filter(function (a, index) {
            return index == 0;
        }).each(function (a) {
            a.click();
        });
    });

    it('Clicking on Internal groups button:', function() {
        element(by.css('button.dropdown-toggle.ng-binding.btn.btn-default')).click();
    });

    it('Unchecking internal groups button:', function(){
        element(by.css('[data-ng-click="deselectAll();"]')).click();
    });

    it('Unchecking checkbox:', function(){
        element(by.css('li.list-group-item.ng-binding.ng-scope')).click();
    });

    it('Unchecking check box', function() {

        element(by.model('data.score_autosourced_resumes')).click();
    });

    it('Clicking on autosource button:', function() {

        browser.sleep(5000);
        element.all(by.css('button.btn.btn-main')).filter(function (button, index) {
            return index == 1;
        }).each(function (button) {
            button.click();
            browser.sleep(15000);
        });
    });

    var newPositionLink = element(by.css('

')); it('verify', function(){ expect(newPositionLink.isPresent()).toEqual(true); browser.sleep(5000); var initial_count_before = element.all(by.css('span.badge.badge-default.ng-binding')).get(0).getText().then(function(text){console.log(text);}) element(by.css('button[ng-click="autoSource()"]')).click(); browser.sleep(10000); }); });

config_values.js

pos_title = 'Python Developer'
project_name = 'AVR'
external_project_name = 'AVR tech'
select_project_name = "avr1"


url = browser.params.siteurl
user = browser.params.login.username
pwd = browser.params.login.password



des = "We're looking for a full stack web developer with between 2-5 years of professional experience.You will take on a central role in developing our products using Python and Django"

我正在从终端执行这样的测试:

sudo protractor conf.js --params.siteurl="http://localhost.com" --params.login.username="raghavendra@gmail.com" --params.login.password="123456"

HTML代码:

<html lang="en" ng-app="hireAlchamyApp" class="ng-scope">

最佳答案 正如@raghavendra所指出的,rootElement已在配置的顶层指定:

exports.config = {
    rootElement: "div"
},
点赞