Domanda

Uso dell'elemento (by.model ()) Sintassi per trovare un campo e un testo di input.

elemento (by.model ('sample_ad.id')). Sendkeys ('batman');

Ottiene l'eccezione da Chromedriver:

Stacktrace:
     Error: Timed out waiting for Protractor to synchronize with the page after 11 seconds
    at Error (<anonymous>)
==== async task ====
WebDriver.executeScript()
    at Protractor.waitForAngular (/Users/jon/dev/project_name/node_modules/protractor/lib/protractor.js:278:22)
    at Protractor.findElement (/Users/jon/dev/project_name/node_modules/protractor/lib/protractor.js:427:8)
    at Object.elementFinder.(anonymous function) [as sendKeys] (/Users/jon/dev/project_name/node_modules/protractor/lib/protractor.js:62:21)
    at null.<anonymous> (/Users/jon/dev/project_name/test/e2e/features/somedirectiveSpec.js:24:39)
    at /Users/jon/dev/project_name/node_modules/protractor/jasminewd/index.js:54:12
==== async task ====
    at null.<anonymous> (/Users/jon/dev/project_name/node_modules/protractor/jasminewd/index.js:53:12)
    at null.<anonymous> (/Users/jon/dev/project_name/node_modules/protractor/node_modules/minijasminenode/lib/async-callback.js:45:37)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
.

Non è sicuro del perché questo è rottura, ma il protrattore sembra molto fragile in questo momento ... Non ho problemi utilizzando l'oggetto del browser per trovare elementi, testo di input, ecc ...

Qualsiasi aiuto sarebbe apprezzato

Modifica: se modifico la riga per quanto segue, sono in grado di interagire con il campo di testo. browser.driver.Findelement (protractor.by.id ('sample_ad_id')). Sendkeys ('Batman');

Altri suggerimenti

Speriamo che questo aiuterà gli altri ....

Trovato questo su GitHub (vedi collegamento riferimenti).Il problema che credo è uno script non tornando, quindi i sendkey non hanno funzionato.Prima di interagire con il DOM utilizzando oggetti di goniometro (elemento, ptor, ecc.), Impostare questa variabile:

browser.ignoresynchronization= true;

Il motivo per cui i seguenti lavori sono perché non si affida alle chiamate Async, interagisce direttamente direttamente con il DOM e inserisce i tasti nel campo di input. browser.driver.Findelement (protractor.by.id ('sample_ad_id')). Sendkeys ('batman');

Il motivo per cui la mia chiamata non ha funzionato ( I credo ) è perché c'era una chiamata ASYNC che non è tornata nel tempo.

Element (by.model ('sample_ad.id')). Sendkeys ('batman');

Riferimenti: https://github.com/angular/protractor/issues/325

Sembra che il tuo test sia scaduto.Il timeout predefinito per il protrattore è di 11 secondi.

Prova a impostare un timeout diverso per questo test:

it('should override timeout', function() {
  // Timeout of 30 seconds.
  element(by.model('sample_ad.id')).sendKeys('batman');
}, 30000)
.

È inoltre possibile sovrascrivere il timeout per tutti i test nel file di configurazione del goniometro.Vedere questo file di configurazione del campione:

https://github.com/andres:dominguez/Protractor-Meetup / Blob / Master / Protractor-config.js # L19

// Inside the protractor config file.
onPrepare: function() {
  // Override the timeout for webdriver.
  var ptor = protractor.getInstance();
  ptor.driver.manage().timeouts().setScriptTimeout(60000);
}
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top