是否有可能在测试Facebook登录的Xcode上编写UI测试?

时间:2016-09-02 10:36:12

标签: xcode facebook xcode-ui-testing ui-testing

我想写一个UI测试,涵盖应用程序上的facebook登录。 我正在努力想到在xcode上实现自动化的方法。 使用SSafariViewController的答案是什么?

2 个答案:

答案 0 :(得分:0)

这是不可能的,您只能与您创建的没有外部软件的应用程序进行交互。

答案 1 :(得分:0)

是的,您可以通过创建对Facebook登录的WebView的引用来实现,类似这样(变量app是在setUp上启动的XCUIApplication引用)

XCUIElement *facebookDialog = (XCUIElement *) [app descendantsMatchingType:XCUIElementTypeWebView];
XCUIElement *emailTextField = (XCUIElement *) facebookDialog.textFields[@"Email or Phone"];
XCUIElement *passwordTextField = facebookDialog.secureTextFields[@"Facebook Password"];
[emailTextField tap];
[emailTextField typeText:emailString];
[passwordTextField tap];
[passwordTextField typeText:passwordString];

[facebookDialog.buttons[@"Log In"] tap];
[facebookDialog.buttons[@"OK"] tap];