2016-11-07 70 views
2

我正在使用量角器測試非角度js網站。browser.wait在測量非角度js網站時無法在量角器中工作

我的測試案例運行成功,但我想刪除睡眠語句,並添加等待或預期的條件,我的測試案例。

我的代碼如下:

var co = require('co'); 
var path = require('path'); 

describe("TEST ", function() { 

    it("test", co.wrap(function*() { 
     browser.ignoreSynchronization = true; 
     var EC = protractor.ExpectedConditions; 
     yield browser.get('URL'); 
     browser.wait(function() { 
      return browser.driver.isElementPresent(by.css(a[href = "#login"])); 
     }, 30000); 
     var elmOK = browser.driver.findElement(by.css('a[href="#login"]')); 
     yield elmOK.click(); 
     expect(browser.getCurrentUrl()).toContain("login"); 
     yield browser.switchTo().frame('here-account-sdk').then(function() { 
      browser.driver.findElement(by.id('sign-in-email')).sendKeys("[email protected]"); 
      browser.driver.findElement(by.id('sign-in-password-encrypted')).sendKeys("voting123"); 
      browser.driver.findElement(by.xpath(' //*[@id="sign-in-form"]/div[2]/div[6]/form/fieldset[3]/button')).click(); 

     }); 
     // browser.sleep(5000); 
     var elmOK = browser.driver.findElement(by.xpath('//*[@id="lnav"]/li[3]/a')); 
     yield elmOK.click(); 
     // browser.sleep(1500); 
     browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[1]/select/option[2]')).click(); 
     // browser.sleep(5000); 

     browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[2]/table/tbody/tr[1]/td[10]/span')).click(); 
     //  browser.sleep(5000); 

     browser.driver.findElement(by.xpath('//*[@id="content"]/div/div[2]/div/div/div/div[3]/button[1]')).click(); 
     // browser.sleep(5000); 
    })); 




}); 

當我嘗試運行我的測試,我得到以下錯誤。我不知道如何解決它。

---------------- Spec started: ----------------                        
F[13:57:01] E/launcher - Cannot read property '_failures' of undefined                            
[13:57:01] E/launcher - TypeError: Cannot read property '_failures' of undefined                         
    at null.self.specDone (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\jasmine-reporters\src\junit_reporter.js:274:46)             
    at dispatch (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1966:28)         
    at ReportDispatcher.specDone (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1949:11)     
    at Spec.specResultCallback [as resultCallback] (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:903:18) 

    at complete (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:368:12)         
    at QueueRunner.clearStack (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:660:9)      
    at QueueRunner.run (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1881:12)       
    at C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1898:16            
    at C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1842:9            
    at C:\Users\jasharma\gitrepo\supplier-portal\node_modules\jasminewd2\index.js:18:5                        
[13:57:01] E/launcher - Process exited with error code 199                               

請幫忙?

+0

你想使用參數'_failures'讀取conf.js文件中的spec結果嗎? –

+0

看看我的迴應在這裏http://stackoverflow.com/questions/40583699/want-to-remove-browser-sleep/40598970#40598970 – mvndaai

回答

0

是這樣的:

yield browser.switchTo().frame('here-account-sdk').then(function() { 
     browser.driver.findElement(by.id('sign-in-email')).sendKeys("[email protected]"); 
     browser.driver.findElement(by.id('sign-in-password-encrypted')).sendKeys("voting123"); 
     browser.driver.findElement(by.xpath(' //*[@id="sign-in-form"]/div[2]/div[6]/form/fieldset[3]/button')).click(); 

    }); 

的唯一部分,你必須是沒有棱角相關?如果是這樣,請嘗試在var elmOK = browser.driver.findElement(by.xpath('//*[@id="lnav"]/li[3]/a'));之前添加browser.switchTo().defaultContent();

+0

嗨@diegovmellet我輸入的網站是非角js – Jatin

相關問題