在面书登录后UITest到页面

时间:2016-03-08 11:29:51

标签: swift xcode-ui-testing uitest

我想测试或写一些单元测试给某些ExampleViewcontroller。例如,标签是否存在。但是如果没有脸书的登录,我们就无法进入此页面。现在我的问题是我如何获得流向该VC的流程,或者我将以编程方式将用户名和密码输入到面书登录页面并按下登录按钮(如app.buttons ["登录"]。 ),在ExampleViewcontroller中执行登录并测试该标签是否存在。

func testExample() {
app.decide()
cellTap()

let cell =  app.collectionViews.elementBoundByIndex(1).cells.elementBoundByIndex(0)
waitForElementToAppear(cell, predicate: existsPredicate, seconds: 60)
XCTAssert(cell.exists)
let query:XCUIElementQuery = app.collectionViews.elementBoundByIndex(1).cells.elementBoundByIndex(0).buttons
XCTAssertTrue(query.elementBoundByIndex(2).exists)
let buyNowButton = query.elementBoundByIndex(2)
sleep(2)
buyNowButton.tap()
XCTAssertTrue(app.staticTexts["Login required"].exists)

app.buttons["ConnectWithFacebook"].tap()/*It is button on on alert box on pressing this it will prompt to face book login webview .How to enter user name and password for those fields and press log in button ?*/

app.buttons["Log In"].tap()

}

0 个答案:

没有答案
相关问题