是否可以在测试 facebook 登录的 Xcode 上编写 UI 测试?
Is it possible to write UI testing on Xcode that tests facebook log in?
我想编写一个 UI 测试来涵盖应用程序上的 facebook 登录。
我正在努力想办法在 xcode 上实现自动化。
使用 SSafariViewController 是答案吗?
不可能,您只能与您创建的应用程序交互,不能使用外部软件。
是的,您可以通过创建对出现 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];
我想编写一个 UI 测试来涵盖应用程序上的 facebook 登录。 我正在努力想办法在 xcode 上实现自动化。 使用 SSafariViewController 是答案吗?
不可能,您只能与您创建的应用程序交互,不能使用外部软件。
是的,您可以通过创建对出现 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];