2015-05-12 130 views
3

我的測試引發以下錯誤。它以前運行良好。請指教。量角器 - 無法運行量角器測試

我的配置文件:

exports.config = { 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    allScriptsTimeout: 20000, 
    baseUrl: 'https://mylink/#/', 

    // frameworks to use 
    frameworks: ['jasmine'], 

// Capabilities to be passed to the webdriver instance. 

    multiCapabilities: [{ 
    'browserName': 'chrome' 
//}, { 
    // 'browserName': 'firefox' 
    // 
    }], 

// Spec patterns are relative to the current working directory. 
    specs: [ 
    'tests/HomePage.js' 
    ], 


    onPrepare: function() { 
    browser.driver.manage().window().maximize(); 
    require('jasmine-reporters'); 
    jasmine.getEnv().addReporter(
     new jasmine.JUnitXmlReporter('xmloutput', true. true)); 
    }, 

    jasmineNodeOpts: { 
    showColors: true 
    } 

} 

我的規格文件:

// spec.js 
describe('MyTest homepage', function() { 
    var ptor; 
    require('protractor-linkuisref-locator')(protractor); 

    beforeEach(function() { 
    browser.ignoreSynchronization = true; 
    ptor = protractor.getInstance(); 
    browser.rootEl = 'div'; 
    //browser.driver.manage().window().setSize(1280, 1024); 
    browser.debugger(); 
    }); 


    it('Should enter homepage url and credentials', function() { 
    browser.get('/#/'); 
    element(by.name('userName')).sendKeys(''); 
    element(by.name('password')).sendKeys(''); 
    element(by.xpath("//button[@class=' btn orange small wide']")).click(); 
    }); 

    it('Should the title contain', function() { 
    expect(browser.getTitle()).toEqual(''); 

    }); 

    it('Should click on the PowerGuide', function() { 
    element(by.linkUiSref('locator')).click(); 
    ptor.sleep(100); 
    //expect(ptor.getCurrentUrl(locator)).toEqual(''); 
    }); 

    it('Should click on Month', function() { 
    element(by.id('month-tab')).click(); 
    ptor.sleep(100); 

    }); 


    //it('Should load the images', function() { 
    // element(by.css('.pure-u-1-2')).click(); 
    //var icons = element.all(by.css('.pure-u-1-2')).click(); 
    //icons.first().click(); 
    //}); 


}); 

這是我得到的錯誤。

 seleniumProcess.pid: 1380 
14:43:45.163 INFO - Launching a standalone server 
Setting system property webdriver.chrome.driver to C:\Users\sramamoorthy\AppData\Roaming\npm\node_modules\protractor\sel 
enium\chromedriver.exe 
14:43:45.342 INFO - Java: Oracle Corporation 25.40-b25 
14:43:45.342 INFO - OS: Windows 7 6.1 amd64 
14:43:45.373 INFO - v2.45.0, with Core v2.45.0. Built from revision 5017cb8 
14:43:45.597 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub 
14:43:45.597 INFO - Version Jetty/5.1.x 
14:43:45.597 INFO - Started HttpContext[/selenium-server,/selenium-server] 
14:43:45.779 INFO - Started [email protected] 
14:43:45.781 INFO - Started HttpContext[/wd,/wd] 
14:43:45.781 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver] 
14:43:45.781 INFO - Started HttpContext[/,/] 
14:43:45.789 INFO - Started SocketListener on 0.0.0.0:4444 
14:43:45.789 INFO - Started [email protected] 
14:44:41.384 INFO - Executing: [new session: Capabilities [{count=1, browserName=chrome}]]) 
14:44:41.399 INFO - Creating a new session for Capabilities [{count=1, browserName=chrome}] 
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 44385 
Only local connections are allowed. 
14:44:43.309 INFO - Done: [new session: Capabilities [{count=1, browserName=chrome}]] 
14:44:43.567 INFO - Executing: [set script timeoutt: 20000]) 
14:44:43.584 INFO - Executing: [delete session: 64c8dac4-559f-416d-b77b-78c5184b6538]) 
14:44:43.590 INFO - Done: [set script timeoutt: 20000] 
14:44:45.303 INFO - Done: [delete session: 64c8dac4-559f-416d-b77b-78c5184b6538] 

測試錯誤:這是我正在那裏我打電話從

Using the selenium server at http://localhost:4444/wd/hub 
[launcher] Running 1 instances of WebDriver 
[launcher] Error: TypeError: undefined is not a function 
    at 
    at Object.exports.run (C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\frameworks\jasmine.js:6 
2:17) 
    at C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:326:35 
    at _fulfilled (C:\Users\sr\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:797:54) 
    at self.promiseDispatch.done (C:\Users\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js: 
826:30) 
    at Promise.promise.promiseDispatch (C:\Users\ppData\Roaming\npm\node_modules\protractor\node_modules\q 
\q.js:759:13) 
[launcher] Process exited with error code 100 

回答

3

的Conf.js文件中的錯誤裏面有onPrepare()一個錯字:

onPrepare: function() { 
    browser.driver.manage().window().maximize(); 
    require('jasmine-reporters'); 
    jasmine.getEnv().addReporter(
     new jasmine.JUnitXmlReporter('xmloutput', true. true)); 
    //           HERE^ 
}, 

你的意思相反:

jasmine.getEnv().addReporter(
    new jasmine.JUnitXmlReporter('xmloutput', true, true)); 
+0

它仍然不會運行。剛注意到硒服務器沒有啓動。我嘗試多次使用webdriver-manager更新 - standalone進行安裝。我在初始化webdriver會話時收到以下消息 C:\ MyTest> webdriver-manager start seleniumProcess.pid:1380 – user2744620

+0

@ user2744620對我來說聽起來像是一個不同的錯誤。很難說,但是如果你替換'框架:['jasmine'],'框架':'茉莉花','? – alecxe

+0

我用完整的錯誤代碼更新了正文。我也嘗試了你的建議。我仍然有同樣的問題。請幫助 – user2744620

0
Error: TypeError: undefined is not a function 
    at 
    at Object.exports.run (C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\frameworks\jasmine.js:6 

錯誤來自庫。我想你可能會錯過圖書館需要的一些依賴。

+0

據我所知..我已經安裝了所有必需的模塊。你建議我應該怎麼做 – user2744620

+0

我安裝了HTMLreporter並刪除了XML輸出行。現在,我看到Chrome瀏覽器啓動並嘗試登錄。輸入用戶名和密碼後,我得到TypeError:Undefined不是函數。我的代碼和上面一樣...我想繼續開發更多。我現在卡住:( – user2744620

+0

嘗試刪除'onPrepare'定義? – davidshen84

0

刪除這條線固定一個類似的問題對我來說:

seleniumAddress: 'http://localhost:4444/wd/hub',