2016-07-06 13 views
0

Ich kann nicht verstehen, wie Sie die acceptAlert() -Methode verwenden. Es funktioniert nicht für mich. Ich versuche eine Popup-Warnung mit zwei Schaltflächen zu akzeptieren: Ok und Abbrechen.Methode acceptAlert() funktioniert nicht in Intern/Leadfoot

Hier ist ein Stück meines Testcodes.

queryDatasource: function (kibiUrl, title, description, datasource, query) { 
    return this.remote 
    .get(require.toUrl(kibiUrl)) 
    .setFindTimeout(3000) 
    .sleep(3000) 
    .findByCssSelector('input[ng-model="query.title"]') 
     .clearValue() 
     .type(title) 
     .end() 
    .findByCssSelector('input[ng-model="query.description"]') 
     .type(description) 
     .end() 
    .findByCssSelector('option[label="'+ datasource +'"]') 
     .click() 
     .end() 
    .findByName('sqlQuery') 
    .findByClassName('ace_text-input') 
     .type(query) 
     .end() 
    .findByXpath('//button[@class="btn btn-success"]') 
     .click() 
     .end() 
    .sleep(1000) 
    .acceptAlert() 
    .then(function (text) { 
     console.log(text); 
    }); 
} 

Und bekomme ich folgende Fehlermeldung:

>> FAIL: chrome on any platform - query mysql datasource (3844ms) 
UnexpectedAlertOpen: [POST http://localhost:4444/wd/hub/session/0c7cbf33-8724-4cfd-8e9c-4434d4570dbb/element/{"using":"css selector","value":"input[ng-model=\"query.title\"]"}] unexpected alert open: {Alert text : Are you sure you want to overwrite MySQL Datasource?} 
    (Session info: chrome=51.0.2704.106) 
    (Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 4.2.0-41-generic x86_64) (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 1 milliseconds: null 
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58' 
System info: host: 'Latitude-E5510', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.2.0-41-generic', java.version: '1.8.0_91' 
Driver info: org.openqa.selenium.chrome.ChromeDriver 
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a), userDataDir=/tmp/.com.google.Chrome.CXLvym}, takesHeapSnapshot=true, databaseEnable 
d=false, handlesAlerts=true, hasTouchScreen=false, version=51.0.2704.106, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] 
Session ID: e9d5caeb7c3f4e3e0819b6b65711aa32 
* Element info: {Using=css selector, value=input[ng-model="query.title"]} 
    at runRequest <node_modules/intern/node_modules/leadfoot/Session.js:88:40> 
    at <node_modules/intern/node_modules/leadfoot/Session.js:109:39> 
    at new Promise <node_modules/intern/node_modules/dojo/Promise.ts:411:3> 
    at ProxiedSession._post <node_modules/intern/node_modules/leadfoot/Session.js:63:10> 
    at ProxiedSession.Session.find <node_modules/intern/node_modules/leadfoot/Session.js:1125:15> 
    at Command.<anonymous> <node_modules/intern/node_modules/leadfoot/Command.js:42:36> 
    at <node_modules/intern/node_modules/dojo/Promise.ts:393:15> 
    at run <node_modules/intern/node_modules/dojo/Promise.ts:237:7> 
    at <node_modules/intern/node_modules/dojo/nextTick.ts:44:3> 
    at nextTickCallbackWith0Args <node.js:415:9> 
    at Command.find <node_modules/intern/node_modules/leadfoot/Command.js:23:10> 
    at Command.prototype.(anonymous function) [as findByCssSelector] <node_modules/intern/node_modules/leadfoot/lib/strategies.js:24:16> 
    at Datasource.queryDatasource </home/trex/Development/Siren/kibi-integration/tests/functional/support/page/Datasource.js:53:9> 
    at Test.query mysql datasource [as test] </home/trex/Development/Siren/kibi-integration/tests/functional/community/index.js:83:11> 
    at <node_modules/intern/lib/Test.js:181:24> 
    at <node_modules/intern/browser_modules/dojo/Promise.ts:393:15> 
    at runCallbacks <node_modules/intern/browser_modules/dojo/Promise.ts:11:11> 
    at <node_modules/intern/browser_modules/dojo/Promise.ts:317:4> 
    at run <node_modules/intern/browser_modules/dojo/Promise.ts:237:7> 
    at <node_modules/intern/browser_modules/dojo/nextTick.ts:44:3> 
>> 1/2 tests failed 
>> 1/2 tests failed 

Antwort

1

Die UnexpectedAlertOpen Fehler bedeutet, dass ein Warnfeld, bevor einer der Fund Anrufe geöffnet; Der Suchaufruf konnte nicht fortgesetzt werden, da er durch einen modalen Warndialog blockiert wurde.

Beachten Sie auch, dass acceptAlert arbeitet mit nativen Browser-Alarm-Boxen, nicht beliebige Framework-generierte Dialoge (wahrscheinlich nicht relevant hier, aber etwas zu beachten).

+0

Sie haben Recht. Ich habe gerade 'acceptAlert()' nach oben gezogen und es hat die Alarmbox erfasst. Danke für die Hilfe. – trex

+0

Hallo, ich kann keine Methode finden, um zu prüfen, ob es eine Warnung gibt? Weißt du es? – trex

Verwandte Themen