2017-05-07 65 views
1

節點版本:v6.9.4量角器點擊功能不起作用,它拋出超時異常錯誤

量角器版本:5.1.1

角版本:1.2.28

瀏覽器(S):Chrome:Version 58.0.3029.96 (64-bit) Chrome WebDriver:Version 2.29

操作系統和版本:MAC OS Siera 10.12.3

量角器配置文件

exports.config = { 
    directConnect: true, 
    capabilities: { 
    'browserName': 'chrome' 
    }, 
    framework: 'jasmine', 
    specs: ['./Test/LoginTest.js'], 
    allScriptsTimeout: 120000, 
    getPageTimeout: 120000, 
    jasmineNodeOpts: { 
    showColors: true, 
    defaultTimeoutInterval: 120000 
} 

一個相關的例子測試

有按鈕的頁面,當我嘗試點擊使用量角器,它將引發超時錯誤。無法點擊該元素。硒webdriver同樣的工作。

步驟來重現 步驟1:使用該URL https://www.neonmob.com/login

步驟2打開網站:Enter the user name and password mentioned below and click on Login button 用戶名:sharif33332 密碼:1234

步驟3:登錄後導航到此URL https://www.neonmob.com/shariftestuser以導航到確切的p發生問題的年齡。

問題Now at this page unable to click on Trade Button and it throws time out exception error.

相同的元素可以使用jQuery找到。請按照上述步驟重現此問題。

用下面的代碼點擊這個按鈕

element(by.css("span[id='trade-btn']")).click();

請讓我知道,如果你不能夠遵循的步驟。我相信這是在protratcor

+0

無法看到交易按鈕XD - 我剛看到它 –

回答

-1

檢查後一個問題,你的第二個URL(似乎沒有)是一個角度頁面,需要ignoreSynchronization。

嘗試使用下面的代碼:

describe('angularjs homepage todo list', function() { 
    it('should add a todo', function() { 
    browser.get('https://www.neonmob.com/login'); 
    element(by.id('field-username')).sendKeys('sharif33332'); 
    element(by.id('field-password')).sendKeys('1234'); 
    element(by.id('signin-btn')).click(); 
    browser.waitForAngular(); 
    browser.ignoreSynchronization=true 
    browser.executeScript('this.document.location = "https://www.neonmob.com/shariftestuser"'); 
    element(by.id('trade-btn')).click(); 
    }); 
}); 

我沒有固定的格式,你可以做到這一點的。 :)

沒什麼特別的配置,以及,我只能用這個:

exports.config = { 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    specs: ['spec.js'], 
    jasmineNodeOpts: {defaultTimeoutInterval: 60000} 
}; 
+0

你曾經通過系統提供的信息嘗試過嗎?那麼你會看到它不會工作,因爲等待角度超時 – wswebcreation

+0

有一個問題,爲什麼你不登錄'shariftestuser'而不是'sharif33332'? 你在這裏測試一個特定的功能嗎? –

+0

頁面「https://www.neonmob.com/shariftestuser」是一個角度頁面。只要打開你的控制檯並鍵入'angular',你就會得到角度對象。當您通過Chrome中的devtools查看DOM時,您還可以在代碼中找到Angular調試信息。 – wswebcreation

1

我發現這個問題。量角器沒有問題。頁面出現問題。你點擊按鈕時沒有超時/沒有找到它。你會收到一個錯誤,因爲Angular沒有發佈頁面,所以頁面超時。仍然有公開的電話或者讓Angular保持未準備好的狀態。這是我

Failures: 
1) click on trade button should click on the trade button 
    Message: 
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. 
    Stack: 
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. 
     at ontimeout (timers.js:365:14) 
     at tryOnTimeout (timers.js:237:5) 
     at Timer.listOnTimeout (timers.js:207:5) 
    Message: 
    Failed: Timed out waiting for asynchronous Angular tasks to finish after 30 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular 
    While waiting for element with locator - Locator: By(css selector, #trade-btn). 
    The following tasks were pending: 
    - $timeout: function(){ownershipPromise=artPieceService.syncOwnership()} 

日誌如果禁用等待角本會工作

describe('click on trade button',() => { 
    beforeEach(function() { 
     browser.get(browser.baseUrl); 
     $('#field-username').sendKeys('sharif33332'); 
     $('#field-password').sendKeys('1234'); 
     $('#signin-btn').click(); 
     browser.driver.wait(() => browser.getCurrentUrl().then((currentUrl) => currentUrl === 'https://www.neonmob.com/sharif33332')); 
     browser.get('https://www.neonmob.com/shariftestuser') 
    }); 

    it('should click on the trade button',() => { 
     // Disable wait for Angular 
     browser.ignoreSynchronization = true; 
     // Wait 2 seconds for the page to be loaded 
     browser.sleep(2000) 
     $('#trade-btn').click(); 
     // Wait to verify that the trade button has been clicked. 
     browser.sleep(5000); 
    }) 
}); 

這將確認有沒有錯,量角器,但你必須潛入角上本頁面/請開發人員修復此問題。

+0

的代碼中解決,如果它是角頁面,則有一個函數在檢查對象之前等待頁面加載。 你也可以使用browser.sleep,但秒數是固定的。 您還可以嘗試使用可充當「waitForAngular」函數的遞歸函數。 http://stackoverflow.com/questions/43656135/changing-protractor-default-timeout-inside-function/43679616#43679616 –

+0

也設置超時到120秒,這並沒有幫助。這意味着睡眠也不會奏效。我認爲頁面上的時間間隔有問題,並保持打開http調用 – wswebcreation

0

@wswebcreation,你確定這不是角度頁面。如果不是那麼角度等待將不起作用。將需要browser.ignoreSynchronization = true。

無論如何,我會要求我們的開發人員對此進行研究並進行調試,以便從應用程序端進行修復。

無論如何目前解決方案提供上述工作正常。

非常感謝你的幫助

+0

嗨,我敢肯定。檢查頁面的源代碼。如果你打開頁面,檢查你將在第567行看到的第一個引用Angular的源代碼,然後在第586行加載角度文件,並在body標籤中'ng-app'參考。無法給出更多證據。 您現在已經接受了錯誤解釋的正確答案。我希望你明白他和我的回答只是一個解決方法(使用'browser.ignoreSynchronization = true'),並且會讓你以正確的方式自動化頁面/應用程序。 – wswebcreation