Sto utilizzando lo strumento "Strumenti" Xcode per creare l'automazione per un'applicazione iOS e devo verificare che l'etichetta per una voce che ho creato nella mia app sia corretta.Come posso verificare il nome di un'etichetta in una vista tabella utilizzando Strumenti su iOS?
Il codice elencato di seguito è, per qualche ragione, non risultante in un passaggio solido o negativo. Al contrario, quando viene eseguito, viene visualizzato un avviso "Problema" nel registro e il test termina senza chiusura esplicita.
Voglio cambiare i miei test in modo da controllare il nome dell'etichetta che so sia stato creato, perché posso vederlo con AccessibilityViewer dopo l'esecuzione dell'automazione.
Se l'etichetta è corretta, desidero registrare il test come passaggio.
Ho usato UIATarget.localTarget().logElementTree()
per mappare il mio albero degli elementi e ho utilizzato AccessibilityInspector per verificare il nome della mia etichetta dopo che la mia voce è stata creata. Il problema è che non riesco a ottenere la sintassi per verificare questo corretto.
Il mio ispettore di accessibilità ha verificato che il nome dell'etichetta sia: MyDogs! e ha i tratti di Static Text e dà il Frame di {{114, 0}, {166,480}}
Osservando l'albero degli elementi - che vorrei incollare qui, sembra l'etichetta si troverebbe in questo cammino:
\Target
-+
--\Application
---+
----\Window
-----+
------\TableView
-------+
--------\TableCell: name:MyDogs! rect:{0, 40},{480,166}}
---------|UIAStaticText: name:MyDogs! value:MyDogs! rect:{{0, 40},{480, 166}}
---------|UIAButton: name:story list share rect:{{439, 41},{33, 28}}
qualcuno può dirmi come diamine verificare questa etichetta?
mio codice attuale assomiglia a questo (ma non è il controllo per l'etichetta - perché non so come):
var testName = "LoginCreateEntry";
//Start test logging
UIALogger.logStart(testName);
//This is supposed to target the entry that my automation has created.
//The flow goes, run the automation that creates the entry, then verify that the entry
//got created as expected and is visible to the user in the iPhone interface.
var myEntry = target.frontMostApp().mainWindow().scrollViews().staticTexts()["My Dogs!"].value();
var entryName = "My Dogs!";
//Do a bunch of UI automation here to create my entry, which results in the entry
//appearing in the mainWindow with the label: My Dogs!
//If myEntry evaluates to true, then call this test a pass.
if (myEntry === entryName) {
UIALogger.logMessage("My entry was created!");
//Mark the test as a PASS
UIALogger.logPass(testName);
}
else {
UIALogger.logMessage("My entry was not created!");
//Mark the test as a FAIL
UIALogger.logFail(testName);
}
//End test
Tutte le risposte o aiuto sarebbero apprezzate !!
--------------------------------- AGGIORNAMENTO ------------ --------------------------
Grazie a tutti per il vostro aiuto! Ho effettivamente ottenuto il valore del titolo e mostrerò la mia soluzione qui sotto. Ma NON POSSO che la funzionalità di registrazione pass/fail funzioni correttamente, non importa quello che faccio - e il problema è stato anche encountered by others. Continuo a ricevere il messaggio arrabbiare
Issue: Script ended without explicting closing this test
alla fine dei miei test. Mi sto convincendo che è un bug con gli strumenti.
Ecco il mio test aggiornato:
var target = UIATarget.localTarget();
var app = UIATarget.localTarget().frontMostApp();
var testName = "LoginCreateEntry";
//Start test logging
UIALogger.logStart(testName);
//Do lots of gui automation stuff here to create the entry which will appear in my app interface.
//I want to verify that the title I gave the entry matches what appears in the app interface
var window = app.mainWindow();
var tableView = window.tableViews()[0];
var tableGroup = tableView.groups()[0];
var entryName = "My Dogs!";
var myEntry = tableView.cells()[0].name(); //<-- This is what I needed!!!
UIALogger.logMessage("My Story Title: " + myEntry); //Print out entry name in log
if (myEntry === entryName) {
UIALogger.logMessage("My entry was created!");
//Mark the test as a PASS
UIALogger.logPass (testName);
} else {
UIALogger.logMessage("My entry was not created!");
//Mark the test as a FAIL
UIALogger.loFails (testName);
}
//End test
Ho apportato alcune modifiche alla tua domanda per portarlo in linea con le preferenze di stile generali su SO così come per darti tag più mirati, spero che questo ti aiuti a ottenere buone risposte. Grande domanda a proposito! –
Qualcosa che potrebbe essere interessante per casi futuri come questo - se trovi la risposta da solo, è apparentemente OK pubblicare la risposta su SO e accettarla. :) Vedi http://meta.stackexchange.com/questions/17845/etiquette-for-answering-your-own-question –