Last active
August 29, 2015 14:14
-
-
Save GuanshanLiu/b8ba764ea8dc1c06a397 to your computer and use it in GitHub Desktop.
As I learn UI Automation with TTPod, the project I work on at Alibaba Inc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
UIALogger.logStart("Testing creating a new playlist") | |
var target = UIATarget.localTarget() | |
var app = target.frontMostApp() | |
var window = app.mainWindow() | |
UIALogger.logMessage("Ensure we are at Mine section by ...") | |
var rootScrollView = window.scrollViews()[0] | |
var mineButton = rootScrollView.buttons()["Mine"] | |
UIALogger.logMessage("... tapping Mine") | |
mineButton.tap() | |
UIALogger.logMessage("Go to Custom Playlists") | |
var homeTableView = window.scrollViews()[1].tableViews()[0] | |
var customPlaylistsCell = homeTableView.cells()["Custom Playlists"] | |
customPlaylistsCell.tap() | |
UIALogger.logMessage("Add new playlist named Test 1") | |
var playlistTableView = window.tableViews()[0] | |
UIATarget.onAlert = function() { | |
return true | |
} | |
var addButton = playlistTableView.buttons()["+ New Playlist"] | |
addButton.tap() | |
UIALogger.logMessage("Remove place holder strings") | |
app.keyboard().keys()["Delete"].tapWithOptions({tapCount:50}) | |
UIALogger.logMessage("Type in Test 1") | |
var title = "Test 1" | |
app.keyboard().typeString(title) | |
app.alert().buttons()["OK"].tap() | |
var cell = playlistTableView.cells()[1] | |
if (cell.name() == title) { | |
UIALogger.logMessage("Add new playlist '" + title + "' successfully!!") | |
} else { | |
throw new Error("Expect '" + title + "' but got '" + cell.name() + "'") | |
} | |
UIALogger.logMessage("Return to Mine") | |
window.buttons()["top bar back"].tap() | |
UIALogger.logPass("Test passed") | |
} catch (exception) { | |
UIALogger.logError(exception.message) | |
UIATarget.localTarget().logElementTree() | |
UIALogger.logFail("Test failed") | |
throw exception | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment