• <legend id='x1nY6'><style id='x1nY6'><dir id='x1nY6'><q id='x1nY6'></q></dir></style></legend>
    <i id='x1nY6'><tr id='x1nY6'><dt id='x1nY6'><q id='x1nY6'><span id='x1nY6'><b id='x1nY6'><form id='x1nY6'><ins id='x1nY6'></ins><ul id='x1nY6'></ul><sub id='x1nY6'></sub></form><legend id='x1nY6'></legend><bdo id='x1nY6'><pre id='x1nY6'><center id='x1nY6'></center></pre></bdo></b><th id='x1nY6'></th></span></q></dt></tr></i><div id='x1nY6'><tfoot id='x1nY6'></tfoot><dl id='x1nY6'><fieldset id='x1nY6'></fieldset></dl></div>

    1. <tfoot id='x1nY6'></tfoot>

        <small id='x1nY6'></small><noframes id='x1nY6'>

          <bdo id='x1nY6'></bdo><ul id='x1nY6'></ul>

        使用 Xcode UI 测试测试 UIWebView

        时间:2023-10-22

            <i id='fN2Se'><tr id='fN2Se'><dt id='fN2Se'><q id='fN2Se'><span id='fN2Se'><b id='fN2Se'><form id='fN2Se'><ins id='fN2Se'></ins><ul id='fN2Se'></ul><sub id='fN2Se'></sub></form><legend id='fN2Se'></legend><bdo id='fN2Se'><pre id='fN2Se'><center id='fN2Se'></center></pre></bdo></b><th id='fN2Se'></th></span></q></dt></tr></i><div id='fN2Se'><tfoot id='fN2Se'></tfoot><dl id='fN2Se'><fieldset id='fN2Se'></fieldset></dl></div>
            <legend id='fN2Se'><style id='fN2Se'><dir id='fN2Se'><q id='fN2Se'></q></dir></style></legend>

          • <tfoot id='fN2Se'></tfoot>
            • <small id='fN2Se'></small><noframes id='fN2Se'>

                <bdo id='fN2Se'></bdo><ul id='fN2Se'></ul>
                  <tbody id='fN2Se'></tbody>

                  本文介绍了使用 Xcode UI 测试测试 UIWebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用来自 XCTest Framework 的新 Xcode UI 测试Xcode 7 GM.我有一个带有简单 UIWebView 的应用程序(它只是一个导航控制器 + 带有 Web 视图和按钮的视图控制器),我想检查以下场景:

                  I'm using new Xcode UI Testing from XCTest Framework with the Xcode 7 GM. I've got an app with simple UIWebView (it's just a navigation controller + view controller with web view and button) and I want to check following scenario:

                  1. 网页视图加载页面www.example.com
                  2. 用户点击按钮
                  3. Web View 加载一些带有 URL 的页面:www.example2.com

                  我想在按下按钮后检查 UIWebView 中加载了哪个页面.现在可以通过 UI 测试实现吗?

                  I want to check which page is loaded in UIWebView after pressing button. Is this possible with UI Testing right now?

                  实际上我得到了这样的网络视图:

                  Actually I'm getting web view like this:

                  let app:XCUIApplication = XCUIApplication()
                  let webViewQury:XCUIElementQuery = app.descendantsMatchingType(.WebView)
                  let webView = webViewQury.elementAtIndex(0)
                  

                  推荐答案

                  您将无法告诉 哪个 页面被加载,就像显示的实际 URL 一样.但是,您可以检查断言内容是否在屏幕上.UI 测试为 XCUIElementQuery" rel="noreferrer">链接对 UIWebViewWKWebView 都有效.

                  You won't be able to tell which page is loaded, as in the actual URL that is being displayed. You can, however, check assert content is on the screen. UI Testing provides a XCUIElementQuery for links that works great with both UIWebView and WKWebView.

                  请记住,页面不会同步加载,因此您必须 等待实际元素出现.

                  Keep in mind that a page doesn't load synchronously, so you will have to wait for the actual elements to appear.

                  let app = XCUIApplication()
                  app.launch()
                  
                  app.buttons["Go to Google.com"].tap()
                  
                  let about = self.app.staticTexts["About"]
                  let exists = NSPredicate(format: "exists == 1")
                  expectationForPredicate(exists, evaluatedWithObject: about, handler: nil)
                  
                  waitForExpectationsWithTimeout(5, handler: nil)
                  XCTAssert(about.exists)
                  
                  XCTAssert(app.staticTexts["Google Search"].exists)
                  app.links["I'm Feeling Lukcy"].tap()
                  

                  还有一个 工作测试主机 与这两个链接一起使用如果你想深入研究代码.

                  There is also a working test host that goes along with the two links if you want to dig into the code.

                  这篇关于使用 Xcode UI 测试测试 UIWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何检测 UIWebView 上的触摸 下一篇:UIWebView 中的 Cookie

                  相关文章

                1. <tfoot id='x65Lu'></tfoot>
                  <i id='x65Lu'><tr id='x65Lu'><dt id='x65Lu'><q id='x65Lu'><span id='x65Lu'><b id='x65Lu'><form id='x65Lu'><ins id='x65Lu'></ins><ul id='x65Lu'></ul><sub id='x65Lu'></sub></form><legend id='x65Lu'></legend><bdo id='x65Lu'><pre id='x65Lu'><center id='x65Lu'></center></pre></bdo></b><th id='x65Lu'></th></span></q></dt></tr></i><div id='x65Lu'><tfoot id='x65Lu'></tfoot><dl id='x65Lu'><fieldset id='x65Lu'></fieldset></dl></div>

                      <bdo id='x65Lu'></bdo><ul id='x65Lu'></ul>

                  1. <small id='x65Lu'></small><noframes id='x65Lu'>

                      <legend id='x65Lu'><style id='x65Lu'><dir id='x65Lu'><q id='x65Lu'></q></dir></style></legend>