久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

量角器找不到 Angular

Protractor fails to find Angular(量角器找不到 Angular)
本文介紹了量角器找不到 Angular的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我似乎無法讓 Protractor 意識到 Angular 已加載并正在運行.當它打開 Chrome 時,我的應用程序在瀏覽器中完全加載,所以我知道 Angular 已正確加載并運行.

I can't seem to get Protractor to realize that Angular is loaded and running. When it opens Chrome my app loads fully in the browser, so I know that Angular is loaded and running correctly.

配置文件:

exports.config = {
seleniumServerJar: 'C:/Dev/PrismWeb/selenium/selenium-server-standalone-2.35.0.jar',

seleniumPort: null,

chromeDriver: 'C:/Dev/PrismWeb/selenium/chromedriver.exe',

seleniumArgs: [],

seleniumAddress: null,

allScriptsTimeout: 110000,

specs: ['c:/dev/prismweb/test/e2e/*.js'],

capabilities: {'browserName': 'chrome'},

baseUrl: 'http://localhost:8080',

rootElement: 'html',

jasmineNodeOpts: {
    onComplete: null,
    isVerbose: true,
    showColors: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 30000
}
};

我只有一個嘗試運行的測試,但它失敗了,因為 Protractor 找不到 Angular.

I've only got one test that I am trying to run and it fails because Protractor can't find Angular.

測試:

describe('homepage loads: ', function(){
var ptor;

    ptor = protractor.getInstance();

    beforeEach(function(){
        ptor.get('/');
    });

it('should load the prism homepage: ', function(){
    var usernameField = ptor.findElement(protractor.By.id("username"));
    //expect(usernameField).toBeDefined();
});
});

這是我得到的錯誤:

UnknownError:javascript 錯誤:未定義角度(會話信息:鉻=30.0.1599.69)(驅動程序信息:chromedriver=2.2,platform=Windows NT 6.1 SP1 x86_64) (警告:服務器沒有提供任何堆棧跟蹤信息)命令持續時間或超時:19 毫秒構建信息:版本:'2.35.0',修訂:'c916b9d',時間:'2013-08-12 15:42:01' 系統信息:os.name:'Windows7',os.arch:'amd64',os.version:'6.1',java.version:'1.7.0_21'會話 ID:1ef7dcd7c5fc9c4e9e1dede050002adf 驅動程序信息:org.openqa.selenium.chrome.ChromeDriver 功能 [{platform=XP,acceptSslCerts=true, javascriptEnabled=true, browserName=chrome,鉻={chromedriverVersion=2.2},可旋轉=假,locationContextEnabled=true,版本=30.0.1599.69,cssSelectorsEnabled=true,databaseEnabled=true,handlesAlerts=true,browserConnectionEnabled=false,webStorageEnabled=true,nativeEvents=true, applicationCacheEnabled=false,takeScreenshot=true}]

UnknownError: javascript error: angular is not defined (Session info: chrome=30.0.1599.69) (Driver info: chromedriver=2.2,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 19 milliseconds Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_21' Session ID: 1ef7dcd7c5fc9c4e9e1dede050002adf Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={chromedriverVersion=2.2}, rotatable=false, locationContextEnabled=true, version=30.0.1599.69, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]

我嘗試將 ng-app 屬性移動到 body 標記(并相應地更改配置),但我得到了同樣的錯誤.我們在 html 標簽上也有一個 ng-controller 屬性,我嘗試將它移到正文中,并在 html 標簽上單獨保留 ng-app 屬性,但結果是一樣的.有人知道為什么會失敗嗎?

I've tried moving the ng-app attribute to the body tag (and changing the config accordingly) but I got the same error. We also have an ng-controller attribute on the html tag, and I tried moving that to the body and leaving the ng-app attribute alone on the html tag, but the result was the same. Does anybody have any insight as to why this fails?

只是一些可能會有所幫助的注釋.我已經更新了上面的測試以包括手動引導工作.Angular 的腳本標簽和所有模塊都位于頁面底部,就在結束 BODY 標簽之前.HTML 標記仍然具有 ng-app="myApp" 屬性和 ng-controller="baseController" 屬性.如果我嘗試在測試中手動引導應用程序,我會得到以下信息:

Just a couple of notes that might help. I've updated the test above to include the manual bootstrapping efforts. The script tags for Angular and all of the modules are located at the bottom of the page, right before the closing BODY tag. The HTML tag still has the ng-app="myApp" attribute plus the ng-controller="baseController" attribute. If I try to bootstrap the app manually in the test, I get the following:

ReferenceError: angular is not defined

讓我擔心的另一件事是,我們使用的其中一個模塊絕對需要$"來映射到 jQuery,所以我們像這樣映射它:

One other thing that worries me is that one of the modules we use absolutely needs "$" to be mapped to jQuery, so we map it like this:

<script type="text/javascript">
    var $jq=jQuery.noConflict();
    var $=jQuery.noConflict();
</script>

ng-app 包含在哪里:

Where the ng-app is included:

<!DOCTYPE html>
<html ng-app="prismApp" ng-controller="baseController">
<head>

推薦答案

我不太確定在 a, it() 中執行 beforeEach() 但是除此之外,你試過等一會兒嗎?顯然,我的意思是 ptor.waitForAngular()ptor.wait()?

I'm not too sure about doing a beforeEach() within a, it() but that aside, have you tried waiting a while? Obviously by this i mean either a ptor.waitForAngular() or a ptor.wait()?

在你的 ptor.get() 之后嘗試 ptor.sleep(10000) 只是為了看看它是否是一個計時的東西.

Try a ptor.sleep(10000) after your ptor.get() just to see if it is a timing thing.

也看看 protractor api以及 wait() 的工作原理:

also take a look at the protractor api and how wait() works:

ptor.wait(function () {
  // Return a condition. Code will continue to run once it is true      
}, 10000); // Only do this for 10 seconds

嘗試 ptor.driver.get('my-page'); 而不是 ptor.get('my-page');

Protractor 現在將 browser 公開為全局,因此您可以只使用 browser.get('index.html#/foo')browser.等待()

Protractor now exposes browser as a global so you can just use browser.get('index.html#/foo') or browser.wait() etc.

這篇關于量角器找不到 Angular的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 日韩av在线一区二区三区 | 亚洲中午字幕 | 日韩av在线免费 | 日韩在线欧美 | 亚洲欧美久久 | 99热热| 一区二区免费在线观看 | 免费精品国产 | 国产精品99久久久久久宅男 | 91电影在线播放 | 成人在线观看免费视频 | 欧美电影网| 一级黄色在线 | 国产一级电影网 | 亚洲欧美中文日韩在线v日本 | 欧美一级欧美三级在线观看 | 成人免费观看视频 | 九九热精品视频 | 中文字幕日韩欧美一区二区三区 | 婷婷在线免费 | 在线国产小视频 | 天天夜夜操 | 国产精品久久久久永久免费观看 | 天天干天天谢 | 亚洲日韩第一页 | 久久99精品国产 | 欧美日韩国产一区二区三区 | 天天操操操操操 | 久久这里只有 | 日韩成人在线观看 | 亚洲天堂av在线 | 中文字幕在线观看一区二区 | 久久国产精品视频 | 99久久精品国产一区二区三区 | 国产一区高清 | 亚洲精品一区av在线播放 | 欧美日韩福利视频 | 四虎影视一区二区 | 亚洲成人精品在线 | 国产在线精品一区二区 | 91嫩草精品|