QWeb(Engine)View Support

QWebView Class

This class, based on Qt WebKit, was in Qt 4.4 to 5.3. It has since been replaced by QWebEngineView.

QWebEngineView Class

Squish provides the same support for the QWebView and QWebEngineView classes in the form of these methods. We will refer to them simply as WebViews here. This support extends to the QML/QtQuick counterparts, also called WebView.

Object clearObjectCache()

This function clears the cache of objects that are being looked up using hierarchical names like DOCUMENT.HTML1.BODY1.DIV2. See also clearObjectCache().

Object evalJS(code)

This function evaluates the JavaScript code string in the WebView's context (i.e., in the context of the active WebView page). The result of the last statement in the code is returned as a string. See also How to Use evalJS.

Object retrieveJSObject(code)

This function evaluates the JavaScript code string in the WebView's context (i.e., in the context of the active WebView page). The result of the last statement in the code is returned as a primitive value, like a string or number, or a reference to a JsObject in the page. (See also How to Use retrieveJSObject and JsObject retrieveJSObject(javascriptcode).)

Boolean isPageLoaded()

This function returns true if the page has been completely loaded; otherwise it returns false. A complete and successful load implies that all of the page's objects can potentially be accessed. This function can be used with the Boolean waitFor(condition) function to wait for a page to be loaded before accessing it from a test script.

Since page loading, HTTP requests, and so on, are asynchronous, even after a call to the isPageLoaded function returns true it is essential that the Object waitForObject(objectOrName) function (or another wait function) is used to ensure that the specific object or objects of interest are ready to be accessed. Also, it may be necessary to pass a longer timeout to the Object waitForObject(objectOrName) function than the default 20 seconds (20 000 milliseconds). See also How to Synchronize Web Page Loading for Testing.

loadUrl(url)

This function changes the WebView's current page to the new url.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Search Results