2016-12-27 5 views
2

私は分度器の新機能です。私は最初のユーザーがアプリケーションにログインし、特定のボタンをクリックして番号を計算する角度のテストを書いています。時にはうまくいくこともあります。分度器のクリック機能が常に機能しているとは限りません

これはコードです:「それは」常に真が、2番目と三番目の作品、時には仕事

describe('Protractor Demo App', function() { 

    it('should login to app', function() { 
     browser.get('http://localhost:8080/main'); 
     var userName = element(by.id('username')); 
     var passWord = element(by.id('pwd')); 
     var loginBtn = element(by.id('loginBtn')); 
     userName.sendKeys('user'); 
     passWord.sendKeys('1'); 
     loginBtn.click(); 
     expect(browser.getCurrentUrl()).toEqual('http://localhost:8080/main/#/intro'); 
    }); 


    it('should calculate something', function() { 
     browser.get('http://localhost:8080/main/#/something'); 
     var next = element(by.css('[ng-click="calculate()"]')); 
     element(by.model('accountNo')).sendKeys('0293949223008'); 
     next.click(); 
     expect(element(by.binding('result')).getText()).toEqual('55017000000029'); 
    }); 

    it('should show error for invalid input no', function() { 
     browser.get('http://localhost:8080/main/#/something'); 
     var next = element(by.css('[ng-click="calculate()"]')); 
     element(by.model('accountNo')).sendKeys('9999456123789'); 
     next.click(); 
     expect(element(by.css('[class="messageObject warning"]')).getText()).toEqual('message for invalid input'); 
    }); 
}); 

まず。そのうちの1人だけが働いていないことが起こった。

これはエラーです:

message: Failed: unknown error: Element ... is not clickable at point (1214, 275). Other element would receive the click: ... (Session info: chrome=55.0.2883.87) (Driver info: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.10240 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 78 milliseconds Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' System info: host: 'user', ip: 'ip', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30), userDataDir='add'}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=55.0.2883.87, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}] Session ID: 45d78fbebf15daa1dde971f5f7470551

私は問題が何であるかを知りません。誰も私を助けることができますか? ありがとうございます。

答えて

7

クリック操作を行う前に、ExpectedConditions.isElementToBeClickable()メソッドを使用してbrowser.wait()を実装します。あなたは以下のように従います:

var EC = protractor.ExpectedConditions; 

it('should show error for invalid input no', function(){ 
    browser.get('http://localhost:8080/main/#/something'); 
    var next = element(by.css('[ng-click="calculate()"]')); 
    element(by.model('accountNo')).sendKeys('9999456123789'); 

    browser.wait(EC.elementToBeClickable(next), 10000,'Element not 
                clickable'); 
    next.click(); 
    expect(element(by.css('[class="messageObject 
    warning"]')).getText()).toEqual('message for invalid input'); 
    }); 
+0

ありがとうございます。それは完璧に動作します。 – navid

+0

@navidようこそ –

関連する問題