2014-11-17 15 views
6

Sto provando a eseguire un test con il goniometro nell'ambiente Amazon EC2 utilizzando il browser PhantomJS. So che non è consigliato all'utente PhantomJS con Protractor ma è l'unica scelta che ho adesso. I test funzionano sempre in ambiente Win7.Perché più richieste GET falliscono il test del goniometro?

Quando il test ha questo aspetto funziona sempre bene

describe('Portal Login End 2 End test', function() { 
    it('should automatically redirect to login /form', function() { 
     browser.get(''); 
     expect(browser.getLocationAbsUrl()).toMatch("/login"); 
    }); 

    it('should automatically redirect to dashboard page after successful login', function() { 
     element(by.model('user.username')).sendKeys('admin'); 
     element(by.model('user.password')).sendKeys('admin'); 
     element(by.buttonText('Sign in')).click(); 
     expect(browser.getLocationAbsUrl()).toMatch("dashboard/home"); 
    }); 
}); 

ma quando una richiesta GET viene effettuata nella funzione beforeeach come questo

describe('Portal Login End 2 End test', function() { 
    beforeEach(function() { 
     browser.get(''); 
    } 
    it('should automatically redirect to login', function() { 
     expect(browser.getLocationAbsUrl()).toMatch("/login"); 
    }); 

    it('should automatically redirect to dashboard page after successful login', function() { 
     element(by.model('user.username')).sendKeys('admin'); 
     element(by.model('user.password')).sendKeys('admin'); 
     element(by.buttonText('Sign in')).click(); 
     expect(browser.getLocationAbsUrl()).toMatch("dashboard/home"); 
    }); 
}); 

i test fallisce la maggior parte del tempo, ma non sempre, con il seguente errore

UnknownError: Error communicating with the remote browser. It may have died. Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33' System info: host: 'ip-10-249-98-182', ip: '10.249.98.182', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-504.el6.x86_64', java.version: '1.6.0_45' Driver info: driver.version: EventFiringWebDriver

Così, quando t wo Le richieste GET vengono eseguite nello stesso test che spesso fallisce, ma quando viene eseguita una sola richiesta, funziona sempre. E come ho scritto sopra, due richieste GET funzionano bene in ambiente Win7 ma non in Linux.

Ho visto alcuni post con questo errore ma non come risolverlo. Qualcuno là fuori con la soluzione?

+0

stesso errore qui .. E avendo difficoltà a risolverlo .. –

risposta

0

Non sono sicuro se beforeEach attende il completamento del lavoro nel browser, ma la funzione it è in attesa. Prova a completare la chiamata get con una funzione it.

describe('Portal Login End 2 End test', function() { 
    beforeEach(function() { 
      it('redirects',function(){browser.get('');}); 
    }); 
    // ..... 
}); 
+1

Grazie per la risposta. Ho provato, ma sembra che prima di tutto non lo accetti poiché è asincrono e non lo è. Ottengo il comportamento casuale anche quando non si usa prima BeforeEach ma una richiesta GET per ogni test. – Ola

0

Se siete problema, come hai detto, è perché il browser non è in attesa del get nel beforeeach, aggiungere browser.waitForAngular();

describe('Portal Login End 2 End test', function() { 
beforeEach(function() { 
    browser.get(''); 
} 
it('should automatically redirect to login', function() { 
    browser.waitForAngular(); 
    expect(browser.getLocationAbsUrl()).toMatch("/login"); 
}); 

it('should automatically redirect to dashboard page after successful login', function() { 
    element(by.model('user.username')).sendKeys('admin'); 
    element(by.model('user.password')).sendKeys('admin'); 
    element(by.buttonText('Sign in')).click(); 
    expect(browser.getLocationAbsUrl()).toMatch("dashboard/home"); 
}); 
}); 

poiché il test viene eseguito in ordine, non è necessario chiamarlo in ogni blocco.

puoi anche provare a chiamare browser.waitForAngular() nella funzione beforeEach, anche se preferisco effettuare la chiamata nella funzione it.

Problemi correlati