2015-05-28 69 views
1

我目前正在處理與我的量角器測試對IE瀏覽器的問題。量角器測試不適用於IE,但它與FF/Chrome/Safari

我用量角器+茉莉+ Node.js的

我是測試頁面的部分如下:

<h2 collapser="" class="title text-center text-uppercase active">Tech Specs <i class="plus-icon"></i></h2> 

我有如下測試:

it('User should be able to see module 11 Tech Specs collapsing and uncolapsing', function() { 
    basePage.techSpecCollapser.click(); 
    browser.sleep(1000); 
    expect(basePage.techSpecContainer.isDisplayed()).toBeTruthy(); 

}); 

這是控制檯輸出:

Landing page module verification --> 
    User should be able to see module 11 Tech Specs collapsing and uncollapsing - fail 


    1) New Landing page module verification --> User should be able to see module 11 Tech Specs collapsing and uncolapsing 
    at 15.446s [Thu, 28 May 2015 14:23:08 GMT] 
    Message: 
    Expected false to be truthy. 
    Stacktrace: 
    Error: Failed expectation 
    at [object Object].<anonymous> (/Users/test/Documents/Dev/test/sandBox/specs/landing_page_spec.js:44:58) 

Finished in 15.448 seconds 
1 test, 1 assertion, 1 failure 

通過觀看測試運行,我看到網頁的一部分沒有顯示。我試過了:

  • 強制滾動頁面的那一部分:沒有用。
  • 聚焦頁面的這一部分:沒有工作。

有沒有人遇到同樣的問題?可以使其工作,這是非常簡單的測試!

回答

1

有許多東西可以嘗試解決這個問題:

  • 運行測試之前,瀏覽器窗口最大化。這種加入onPrepare()

    browser.driver.manage().window().maximize(); 
    
  • 去除不可靠browser.sleep()並明確等待元素與visibilityOf expected condition變得可見:

    var EC = protractor.ExpectedConditions; 
    basePage.techSpecCollapser.click(); 
    browser.wait(EC.visibilityOf(basePage.techSpecContainer), 10000); 
    
  • 移動的元素:

    browser.executeScript("arguments[0].scrollIntoView();", basePage.techSpecContainer.getWebElement()); 
    
+0

感謝@alecxe,但我仍然一樣爲此輸出。我已經添加了所有你所建議的內容,一個接一個地提出你的建議!但仍似乎沒有顯示該頁面的一部分,我想可能是沒有正確點擊上一個元素。還有什麼其他建議? –

+0

@BrunoSoko很好,很難說沒有能夠調試的問題。在黑暗中的另一個鏡頭,嘗試按以下方式執行單擊:'browser.executeScript(「arguments [0] .click();」,basePage.techSpecCollapser.getWebElement());'。 – alecxe

+0

你說得對。你在這裏被蒙上眼睛,我帶着不同的錯誤,但是通過添加這個'browser.manage()。timeouts()。隱式地等待(100000);'con config.js文件並且在我的測試中這樣做: ''' ();(函數()){function.(){browser.wait(EC.visibilityOf(thxPage.thankYou),90000); expect(thxPage.thankYou.isPresent())。toBeTruthy(); } ); ''' –

相關問題