### Start Example Web Server (Linux/macOS) Source: https://doc.qt.io/squish/squish-for-web-tutorials.html Run the Python script to start the web server for the Address Book example. Ensure you are in the example directory or provide the correct path to the script. ```bash $ python /examples/web/addressbook/server.py ``` -------------------------------- ### Start Example Web Server (macOS Python Framework) Source: https://doc.qt.io/squish/squish-for-web-tutorials.html Use the Python framework path to start the web server on macOS. This command is specific to the Python installation within the Python.framework. ```bash $ cd /examples/web/addressbook $ ../../../python/Python.framework/Versions/Current/bin/python server.py ``` -------------------------------- ### Start Example Web Server (Windows) Source: https://doc.qt.io/squish/squish-for-web-tutorials.html Navigate to the example directory and execute the Python server script. This command assumes Python is in your PATH or you are using the provided Python executable. ```batch C:\> cd \examples\web\addressbook \examples\web\addressbook> ..\..\..\python\python server.py ``` -------------------------------- ### Example: Start Squish Adapter for RQM Source: https://doc.qt.io/squish/ibm-rational-quality-manager-integration.html Example command to connect the Squish Adapter to a specific RQM server, user, and project. Ensure Squish and configuration directories are correctly specified. ```bash start.bat -repository https://192.168.1.42:9443/qm -user bert -password xxxyz -squishDir C:\Squish -configDir C:\SquishAdapterConfigs -projectArea froglogic ``` -------------------------------- ### Get Example Test Suites Source: https://doc.qt.io/squish/squish-for-qt-tutorials-mbt.html Access example test suites for the Squish MBT tutorial. These suites are located in the /examples/qt/addressbook directory and demonstrate different stages of the tutorial. ```bash "/examples/qt/addressbook" ``` -------------------------------- ### Install and Start Squish License Server Service on macOS Source: https://doc.qt.io/squish/setting-up-the-squish-floating-license-server.html Install and start the Squish license server as a service on macOS using the provided command. This requires sudo privileges. ```bash sudo /opt/squish-license-server/bin/licenseserver --install-service ``` -------------------------------- ### Start Unattended Installation Source: https://doc.qt.io/squish/installing-from-binary-packages.html Invoke the Squish installation program with the 'unattended=1' argument to launch without a graphical user interface. Progress and errors are reported to the console. ```bash $ ./squish-9.1.0-windows unattended=1 more options... ``` -------------------------------- ### Start AUT with Window Title Source: https://doc.qt.io/squish/cli-startaut.html Example of starting startwinaut with a window title, using cmd.exe's 'start' command to ensure a new console window. ```bash c:\> start $SQUISHDIR/bin/startwinaut --window-title=somewindow ``` -------------------------------- ### Start Application in Ruby Source: https://doc.qt.io/squish/tutorials-java.html Starts the AUT using its registered name or a path. Pass the AUT name as a string. This example uses an environment variable for the path. ```ruby require 'squish' require 'names' include Squish def main startApplication("#{ENV['SQUISH_PREFIX']}/examples/java/addressbook/AddressBookSwing.jar") activateItem(waitForObjectItem(Names::Address_Book_JMenuBar, "File")) activateItem(waitForObjectItem(Names::File_JMenu, "Open...")) ``` -------------------------------- ### Tcl: Start Application and Attach to Browser Source: https://doc.qt.io/squish/attaching-to-a-running-web-browser.html This Tcl snippet demonstrates starting an application, setting up web wrappers, starting a web application, and attaching to a browser. It also shows how to switch application contexts. ```tcl proc main {} { set autContext [startApplication "addressbook"] # [ ... interactions with the AUT ... ] testSettings setWrappersForApplication __squish__webhook {Web} set webContext [startApplication "__squish__webhook"] invoke attachToBrowser "*froglogic*" # [ ... interactions with the Website ... ] setApplicationContext $autContext # [ ... interactions with the addressbook AUT again ... ] setApplicationContext $webContext # [ ... interactions with the Website again ... ] # detach from the browser invoke closeWindow ":[Window]" } ``` -------------------------------- ### Configure SNMP Setup Source: https://doc.qt.io/squish/how-to-use-the-web-api.html Use this command to perform a basic setup for SNMP. Ensure SNMP is installed and configured on the web server. ```bash snmpconf -g basic_setup ``` -------------------------------- ### Python: Start Application and Attach to Browser Source: https://doc.qt.io/squish/attaching-to-a-running-web-browser.html This Python snippet demonstrates starting an application, setting up web wrappers, starting a web application, and attaching to a browser. It also shows how to switch application contexts. ```python def main() autContext = startApplication("addressbook") # [ ... interactions with the AUT ... ] testSettings.setWrappersForApplication("__squish__webhook", ["Web"]) webContext = startApplication("__squish__webhook") attachToBrowser("*froglogic*") # [ ... interactions with the Website ... ] setApplicationContext(autContext) # [ ... interactions with the addressbook AUT again ... ] setApplicationContext(webContext) # [ ... interactions with the Website again ... ] # detach from the browser closeWindow(":[Window]") end ``` -------------------------------- ### Start Application in JavaScript Source: https://doc.qt.io/squish/tutorials-java.html Starts the AUT using its registered name or a path. Pass the AUT name as a string. This example uses an environment variable for the path. ```javascript import * as names from 'names.js'; function main() { startApplication('"' + OS.getenv("SQUISH_PREFIX") + '/examples/java/addressbook/AddressBookSwing.jar"'); activateItem(waitForObjectItem(names.addressBookJMenuBar, "File")); activateItem(waitForObjectItem(names.fileJMenu, "Open...")); ``` -------------------------------- ### Launch Webhook and Attach to Browser (Python) Source: https://doc.qt.io/squish/attaching-to-a-running-web-browser.html A Python example demonstrating how to start an AUT, then launch the `__squish__webhook` to attach to a browser. It covers context switching between applications. ```Python def main(): autContext = startApplication("addressbook") # [ ... interactions with the AUT ... ] testSettings.setWrappersForApplication("__squish__webhook", ["Web"]) webContext = startApplication("__squish__webhook") attachToBrowser("*froglogic*") # [ ... interactions with the Website ... ] setApplicationContext(autContext) # [ ... interactions with the addressbook AUT again ... ] setApplicationContext(webContext) # [ ... interactions with the Website again ... ] # detach from the browser ``` -------------------------------- ### Installing QML Extensions Source: https://doc.qt.io/squish/how-to-use-the-qml-extension-api.html Instructions on how to install QML extensions by placing them in specific directories or by setting environment variables. ```APIDOC ## Installing QML Extensions Squish automatically searches for QML extensions in the following directories: * **QtQuick 1.x:** `/lib/extensions/qt/qml` * **QtQuick 2.x:** `/lib/extensions/qt/qtquick` To install an extension, simply copy or move the `.qml` file into the appropriate directory. Alternatively, you can specify a custom directory for Squish to search: * **QtQuick 1.x:** Set the `SQUISH_QML_EXTENSION_PATH` environment variable to your custom directory. * **QtQuick 2.x:** Set the `SQUISH_QTQUICK_EXTENSION_PATH` environment variable to your custom directory. ``` -------------------------------- ### Launch Webhook and Attach to Browser (JavaScript) Source: https://doc.qt.io/squish/attaching-to-a-running-web-browser.html This JavaScript example demonstrates starting a primary AUT, then launching the `__squish__webhook` to attach to a browser. It shows how to switch application contexts between the two. ```JavaScript function main() { var autContext = startApplication("addressbook"); // [ ... interactions with the AUT ... ] testSettings.setWrappersForApplication("__squish__webhook", ["Web"]); var webContext = startApplication("__squish__webhook"); attachToBrowser("*froglogic*"); // [ ... interactions with the Website ... ] setApplicationContext(autContext); // [ ... interactions with the addressbook AUT again ... ] setApplicationContext(webContext); // [ ... interactions with the Website again ... ] // detach from the browser closeWindow(":[Window]"); } ``` -------------------------------- ### Execute Install Command (Linux) Source: https://doc.qt.io/squish/installing-squish-for-qt-from-source-packages.html Change to the build directory and execute the install command, specifying the destination directory. ```bash $ ./build install DESTDIR= ``` -------------------------------- ### Execute Install Command (Windows) Source: https://doc.qt.io/squish/installing-squish-for-qt-from-source-packages.html Change to the build directory and execute the install command, specifying the destination directory. ```batch SQUISHBUILD> build install DESTDIR= ``` -------------------------------- ### Prepare Installation Directory (Linux) Source: https://doc.qt.io/squish/installing-squish-for-qt-from-source-packages.html Before installing, navigate to the Squish directory and remove old extensions and libraries. Back up the paths.ini file. ```bash $ rm -r lib/extensions/qt $ rm lib/libsquishqt* $ cp etc/paths.ini etc/paths.ini.bak ``` -------------------------------- ### Start Application in Tcl Source: https://doc.qt.io/squish/tutorials-java.html Starts the AUT using its registered name or a path. Pass the AUT name as a string. This example uses an environment variable for the path. ```tcl source [findFile "scripts" "names.tcl"] proc main {} { startApplication "$::env(SQUISH_PREFIX)/examples/java/addressbook/AddressBookSwing.jar" invoke activateItem [waitForObjectItem $names::Address_Book_JMenuBar "File"] invoke activateItem [waitForObjectItem $names::File_JMenu "Open..."] ``` -------------------------------- ### Prepare Installation Directory (Windows) Source: https://doc.qt.io/squish/installing-squish-for-qt-from-source-packages.html Before installing, navigate to the Squish directory and remove old extensions and libraries. Back up the paths.ini file. ```batch SQUISHDIR> copy etc\paths.ini etc\paths.ini.bak SQUISHDIR> rd /q /s lib\extensions\qt SQUISHDIR> del /q bin\winhook.dll bin\squishqt*.dll ``` -------------------------------- ### Start Squish Adapter with Arguments Source: https://doc.qt.io/squish/ibm-rational-quality-manager-integration.html Use this command to start the Squish Adapter and configure its connection to the RQM server. Arguments are written to Config.ini on the first run. ```bash start.bat -repository https://:/ -user -userFile -password -passwordFile -squishDir -configDir -projectArea ``` ```bash start.sh -repository https://:/ -user -userFile -password -passwordFile -squishDir -configDir -projectArea ``` -------------------------------- ### Start Application in Perl Source: https://doc.qt.io/squish/tutorials-java.html Starts the AUT using its registered name or a path. Pass the AUT name as a string. This example uses an environment variable for the path. ```perl require 'names.pl'; sub main { startApplication("\"$ENV{'SQUISH_PREFIX'}/examples/java/addressbook/AddressBookSwing.jar\""); activateItem(waitForObjectItem($Names::address_book_jmenubar, "File")); activateItem(waitForObjectItem($Names::file_jmenu, "Open...")); ``` -------------------------------- ### Start Application in Python Source: https://doc.qt.io/squish/tutorials-java.html Starts the AUT using its registered name or a path. Pass the AUT name as a string. This example uses an environment variable for the path. ```python import names import os def main(): startApplication('"' + os.environ["SQUISH_PREFIX"] + '/examples/java/addressbook/AddressBookSwing.jar"') activateItem(waitForObjectItem(names.address_Book_JMenuBar, "File")) activateItem(waitForObjectItem(names.file_JMenu, "Open...")) ``` -------------------------------- ### Start Qt, macOS, and Tk AUTs with startaut Source: https://doc.qt.io/squish/cli-startaut.html Use `startaut` to launch Qt, macOS, and Tk applications. Specify the toolkit with `--wrapper` if not Qt. The `--port` option is for communication, while `--uses-builtin-hook` is for attachable built-in hooks; these two options are mutually exclusive. ```bash startaut --port=1234 my_qt_app --some-option ``` ```bash startaut --wrapper=Tk --cwd=/path/to/app --uses-builtin-hook my_tk_app ``` -------------------------------- ### Start Application and Go Home (Tcl) Source: https://doc.qt.io/squish/how-to-test-android-applications.html This Tcl snippet starts the Squish access application and goes to the home screen. Ensure the 'org.qtproject.squishaccessapp' is installed on the Android device. ```tcl startApplication "org.qtproject.squishaccessapp" goHome ``` -------------------------------- ### startaut Source: https://doc.qt.io/squish/cli-startaut.html Starts Qt, macOS, and Tk AUTs, with options for verbosity, toolkit specification, working directory, output capturing, and port configuration. ```APIDOC ## startaut ### Usage `startaut` [`--verbose`] [`--wrapper=`_toolkit_] [`--cwd=`_working-directory_] [`--capture-output`] `--port=`_port_ _aut_ [_aut-command-line-options_] or: `startaut` [`--verbose`] [`--wrapper=`_toolkit_] [`--cwd=`_working-directory_] `--uses-builtin-hook` _aut_ [_aut-command-line-options_] ### Parameters #### Options - `--verbose` (flag) - Show Squish internal log messages on the command line. Log messages are output to standard error. - `--wrapper` (_toolkit_) - Specify the AUT's GUI toolkit. Must be one of `Qt`, `Mac`, or `Tk`. Defaults to `Qt` if not specified. - `--cwd` (_working-directory_) - Specify the working directory for the AUT. - `--capture-output` (flag) - Suppress all AUT output. Has no effect if `SQUISH_NO_CAPTURE_OUTPUT` environment variable is set to non-zero. Has no effect when used with `--uses-builtin-hook`. - `--port` (_port_) - Specify the port number for Squish to communicate with the AUT. Cannot be used with `--uses-builtin-hook`. - `--uses-builtin-hook` (flag) - Specify that the AUT uses the attachable built-in Hook. Cannot be used with `--port`. #### Arguments - _aut_ - The AUT executable. - _aut-command-line-options_ - Any additional options to be passed to the AUT. ### Notes - Log messages are output to the standard error channel. ``` -------------------------------- ### Add Managed Server Installation in Squish IDE Source: https://doc.qt.io/squish/preferences-dialog.html Add Squish installations to the Squish IDE configuration to start further squishserver instances. Use 'Add' > 'Managed server'. ```text Add > Managed server ``` -------------------------------- ### goQuickSettings() Source: https://doc.qt.io/squish/android-goquicksettings-function.html Opens the Android quick-settings panel. Requires UiAutomation to be enabled; otherwise, it throws an exception. ```APIDOC ## goQuickSettings() ### Description This function opens the Android quick-settings when UiAutomation is enabled. Otherwise, this function throws an exception. ### Method N/A (This appears to be a function call within a specific context, not a standard REST API endpoint) ### Endpoint N/A ### Parameters None explicitly defined for the function call itself, but relies on the 'UiAutomation' context. ### Request Example ``` // Assuming a context where goQuickSettings() can be called goQuickSettings() ``` ### Response #### Success Response Opens the Android quick-settings panel. #### Response Example N/A (The action is a UI interaction, not a data response) ``` -------------------------------- ### Example Script-Based Test Case Source: https://doc.qt.io/squish/squish-for-macos-tutorials.html This is an example of a script-based test case for the address book application. It demonstrates starting the application, interacting with UI elements, and performing a verification. ```python def main(): startApplication("SquishAddressBook") mouseClick(waitForObject(names.address_Book_Untitled_New_NSToolbarItem)) test.compare(waitForObjectExists(names.address_Book_Untitled_NSTableView).numberOfRows(), 0) ``` ```javascript function main() { startApplication("SquishAddressBook"); mouseClick(waitForObject(names.addressBookUntitledNewNSToolbarItem)); test.compare((waitForObjectExists(names.addressBookUntitledNSTableView)).numberOfRows(), 0); } ``` ```perl sub main { startApplication("SquishAddressBook"); mouseClick(waitForObject($Names::address_book_untitled_new_nstoolbaritem)); test.compare(waitForObjectExists($Names::address_book_untitled_nstableview).numberOfRows(), 0) } ``` ```ruby def main startApplication("SquishAddressBook") mouseClick(waitForObject(Names::Address_Book_Untitled_New_NSToolbarItem)) Test.compare(waitForObjectExists(Names::Address_Book_Untitled_NSTableView).numberOfRows(), 0) end ``` -------------------------------- ### Start AUT with startaut Source: https://doc.qt.io/squish/attaching-to-running-applications.html Use this command to start the AUT and make it listen on a specified network port for Squish to connect to. Ensure the `--port` option precedes the AUT executable. ```bash startaut --verbose --port=9999 addressbook ``` -------------------------------- ### Start Application and Common Script in Ruby Source: https://doc.qt.io/squish/how-to-use-the-java-api.html Initializes the test by starting the target application and loading common utility scripts. This is a standard setup for many Squish tests. ```ruby startApplication("#{ENV['SQUISH_PREFIX']}/examples/java/paymentform_swt/PaymentFormSWT.jar") require findFile("scripts", "common.rb") ``` -------------------------------- ### License Server Settings Example Source: https://doc.qt.io/squish/license-server.html Example configuration for [License] and [REST] sections in the Squish License Server settings file. Modify LeaseTime and AllowExecutionsToUseTesterLicenses for license management, and AnonymousReadAccess, ListenAddress, ListenPort, and ReadAccessTokens for REST API access. ```ini [License] LeaseTime=0 AllowExecutionsToUseTesterLicenses=true ``` ```ini [REST] AnonymousReadAccess=true ListenAddress= ListenPort= ReadAccessTokens= ``` -------------------------------- ### Squish startaut Tool on Unix-like Systems Source: https://doc.qt.io/squish/changes-in-4-0-beta-3.html The `startaut` tool now functions correctly on Unix-like systems even if the `SQUISH_LIBQTDIR` environment variable is not set. This simplifies the setup process for cross-platform testing. ```bash startaut ``` -------------------------------- ### Start Application and Open Menu (Ruby) Source: https://doc.qt.io/squish/squish-for-java-swt-tutorials.html Launches the AUT and selects a menu item in Ruby. Requires 'squish' and 'names' libraries, and uses environment variables. ```ruby require 'squish' require 'names' include Squish def main fn = File.join(ENV['SQUISH_PREFIX'], "examples/java/addressbook_swt/AddressBookSWT.jar") startApplication('"' + fn + '"'); activateItem(waitForObjectItem(Names::Address_Book_Menu, "File")) activateItem(waitForObjectItem(Names::File_Menu, "Open...")) ``` -------------------------------- ### Start Application and Go Home (JavaScript) Source: https://doc.qt.io/squish/how-to-test-android-applications.html Use this JavaScript snippet to start the Squish access application and navigate to the home screen. Ensure the 'org.qtproject.squishaccessapp' package is installed on the Android device. ```javascript startApplication("org.qtproject.squishaccessapp") goHome() ``` -------------------------------- ### Handle MessageBoxOpened Event (Ruby) Source: https://doc.qt.io/squish/how-to-use-event-handlers.html Installs an event handler to log and close message boxes when they appear. Requires Squish and includes a main function to start the application and install the handler. ```ruby # encoding: UTF-8 require 'squish' include Squish def HandleMessageBox(messageBox) Test.log("MessageBox opened: '%s' - '%s'" % [ messageBox.windowText, messageBox.text]) messageBox.close end def main startApplication("myapp") installEventHandler("MessageBoxOpened", "HandleMessageBox") ... end ``` -------------------------------- ### Start AUT and Verify Window Visibility (Python) Source: https://doc.qt.io/squish/squish-for-macos-tutorials.html Starts the AUT and verifies that the main window is visible. Ensure the SQUISH_PREFIX environment variable is set. ```python @Given("the address book application is running") def step(context): startApplication('"' + os.environ["SQUISH_PREFIX"] + '/examples/mac/addressbook/SquishAddressBook"') test.compare(waitForObjectExists(names.o_NSWindow).isVisible, 0) ``` -------------------------------- ### Handle Crash Event (Ruby) Source: https://doc.qt.io/squish/how-to-use-event-handlers.html Installs an event handler to log a message and delete lock files when the AUT crashes. Requires Squish and includes a main function to start the application and install the handler. ```ruby # encoding: UTF-8 require 'squish' include Squish def crashHandler Test.log("Deleting lock files after AUT crash") deleteLockFiles end def main startApplication("myapp") installEventHandler("Crash", "crashHandler") ... end ``` -------------------------------- ### Handle Crash Event (Python) Source: https://doc.qt.io/squish/how-to-use-event-handlers.html Installs an event handler to log a message and delete lock files when the AUT crashes. Requires Squish and includes a main function to start the application and install the handler. ```python def crashHandler(): test.log("Deleting lock files after AUT crash") deleteLockFiles() def main(): startApplication("myapp") installEventHandler("Crash", "crashHandler") ... ``` -------------------------------- ### Start Attachable AUT with Built-in Hook Source: https://doc.qt.io/squish/squish-s-c-api.html Use the `startaut` command with the `--uses-builtin-hook` option to launch the AUT and make it listen on the specified port for Squish to attach. ```bash startaut --uses-builtin-hook aut ``` -------------------------------- ### Get Top-Level Objects in Tcl Source: https://doc.qt.io/squish/object-toplevelobjects-function.html This Tcl example retrieves all top-level objects from the AUT and iterates through them to access their children. ```tcl set topLevels [object topLevelObjects] foreach obj $topLevels { set children [object children $obj] ... } ``` -------------------------------- ### Handle QMouseEvent on QCheckBox (Ruby) Source: https://doc.qt.io/squish/how-to-use-event-handlers.html Installs an event handler to log when a QCheckBox is clicked. This handler is called for all QCheckBox objects when a QMouseEvent occurs. Requires Squish and includes a main function to start the application and install the handler. ```ruby # encoding: UTF-8 require 'squish' include Squish def handleCheckBox(obj) Test.log("QCheckBox '%s' clicked" % [objectName(obj)]) end def main startApplication("myapp") installEventHandler("QCheckBox", "QMouseEvent", "handleCheckBox") ... end ``` -------------------------------- ### Start AUT and Verify Window Visibility (Perl) Source: https://doc.qt.io/squish/squish-for-macos-tutorials.html Launches the AUT and verifies the main window's visibility. Ensure the SQUISH_PREFIX environment variable is set. ```perl Given("the address book application is running", sub { my $context = shift; startApplication("\"$ENV{'SQUISH_PREFIX'}/examples/mac/addressbook/SquishAddressBook\""); test::compare(waitForObjectExists($Names::address_book_untitled_nswindow)->isVisible, 1); }); ``` -------------------------------- ### Handle QMouseEvent on QCheckBox (Python) Source: https://doc.qt.io/squish/how-to-use-event-handlers.html Installs an event handler to log when a QCheckBox is clicked. This handler is called for all QCheckBox objects when a QMouseEvent occurs. Requires Squish and includes a main function to start the application and install the handler. ```python def handleCheckBox(obj): test.log("QCheckBox '%s' clicked" % objectName(obj)) def main(): startApplication("myapp") installEventHandler("QCheckBox", "QMouseEvent", "handleCheckBox") ... ``` -------------------------------- ### Start Squish Server with Port Source: https://doc.qt.io/squish/version-6-3.html When using the --port switch with startwinaut, status and error messages are now printed to simplify diagnosing attachment issues. ```bash startwinaut --port ``` -------------------------------- ### Example Script-Based Test Case in Multiple Languages Source: https://doc.qt.io/squish/squish-for-ios-tutorials.html This snippet shows an example of a script-based test case for the 'Elements' application in Python, JavaScript, Perl, Ruby, and Tcl. It demonstrates starting the application, tapping an object, and verifying the text of a search bar. ```python def main(): startApplication("Elements") tapObject(waitForObject(names.search_UILabel), 179, 9) test.compare(waitForObjectExists(names.o_UISearchBarTextField).text, "") ``` ```javascript function main() { startApplication("Elements"); tapObject(waitForObject(names.searchUILabel), 179, 9); test.compare(waitForObjectExists(names.uISearchBarTextField).text, ""); } ``` ```perl sub main { startApplication("Elements"); tapObject(waitForObject($Names::search_uilabel), 179, 9); test::compare(waitForObjectExists($Names::uisearchbartextfield)->text, ""); } ``` ```ruby def main startApplication("Elements") tapObject(waitForObject(Names::Search_UILabel), 179, 9) test.compare(waitForObjectExists(Names::UISearchBarTextField).text, "") end ``` ```tcl proc main {} { startApplication "Elements" invoke tapObject [waitForObject $names::Search_UILabel] 179 9 test compare [property get [waitForObjectExists $names::UISearchBarTextField] text] "" } ``` -------------------------------- ### Install Signal Handler for QTableWidget Item Changes (JavaScript) Source: https://doc.qt.io/squish/how-to-use-the-qt-api.html This JavaScript snippet installs a handler for the 'itemChanged' signal of a QTableWidget. The handler logs the symbolic name of the emitting object and the text of the changed QTableWidgetItem. Call this after starting the AUT and ensuring the widget exists. ```javascript function tableItemChangedHandler(obj, item) { test.log('itemChanged emitted by object "' + objectMap.symbolicName(obj) + '" on item "' + item.text() + '"'); } function main() { startApplication("addressbook"); // ... various actions ... now the table widget exists installSignalHandler(table, "itemChanged(QTableWidgetItem*)", "tableItemChangedHandler"); // ... the rest of the test ... } ``` -------------------------------- ### Install Signal Handler for QTableWidget Item Changes (Ruby) Source: https://doc.qt.io/squish/how-to-use-the-qt-api.html This Ruby snippet installs a handler for the 'itemChanged' signal of a QTableWidget. The handler logs the object's symbolic name and the text of the changed item. Call this after starting the AUT and confirming the widget's existence. ```ruby def tableItemChangedHandler(obj, item) name = objectMap.symbolicName(obj) text = item.text() Test.log("itemChanged emitted by object '#{name}' on item '#{text}'") end def main startApplication("addressbook") # ... various actions ... now the table widget exists installSignalHandler(table, "itemChanged(QTableWidgetItem*)", "tableItemChangedHandler") # ... the rest of the test ... end ``` -------------------------------- ### Start Application and Mark Missing Step (Tcl) Source: https://doc.qt.io/squish/squish-for-win-tutorials-mbt.html Use this snippet to start the AUT and mark a step as needing implementation. Ensure Squish is hooked to the AUT before calling startApplication. ```tcl mbt step "Create new address book" {} { startApplication "Addressbook" test warning "TODO implement Create new address book" } ``` -------------------------------- ### Install Signal Handler for QTableWidget Item Changes (Python) Source: https://doc.qt.io/squish/how-to-use-the-qt-api.html Use this Python snippet to install a signal handler for the 'itemChanged' signal of a QTableWidget. The handler logs the object name and the text of the changed item. Ensure the AUT is started and the table widget exists before calling. ```python def tableItemChangedHandler(obj, item): test.log('itemChanged emitted by object "%s" on item "%s"' % ( objectMap.symbolicName(obj), item.text())) def main(): startApplication("addressbook") # ... various actions ... now the table widget exists installSignalHandler(table, "itemChanged(QTableWidgetItem*)", "tableItemChangedHandler") # ... the rest of the test ... ``` -------------------------------- ### Start AUT and Verify Window Visibility (Ruby) Source: https://doc.qt.io/squish/squish-for-macos-tutorials.html Starts the AUT and checks if the main window is visible. Requires the ENV['SQUISH_PREFIX'] to be set. ```ruby Given("the address book application is running") do |context| startApplication("\"#{ENV['SQUISH_PREFIX']}/examples/mac/addressbook/SquishAddressBook\"") Test.compare(waitForObjectExists(Names::O_NSWindow).isVisible, 0) end ``` -------------------------------- ### Start Multiple AUTs and Set Active Context (Ruby) Source: https://doc.qt.io/squish/how-to-test-multiple-auts-from-a-single-test-script-using-applicationcontext.html Starts a server and two clients, then sets the context to the first client to send a message, and switches to the second client to verify receipt. Requires Squish for Qt and native Windows application wrappers. ```ruby startApplication("chatserver") client1 = startApplication("chatclientqt") testSettings.setWrappersForApplication("chatclientwin", ("Windows")) client2 = startApplication("chatclientwin", "localhost", 2001) setApplicationContext(client1) editor = waitForObject("ChatWindow.messageEditor") type(editor, "Message for client #2") setApplicationContext(client2) msgView = waitForObject("ChatWindow.messageView") Test.compare(msgView.text, "Message for client #2") ``` -------------------------------- ### Perl Test Script Example Source: https://doc.qt.io/squish/squish-for-ios-tutorials.html A Perl script demonstrating Squish test automation, including starting applications and interacting with UI elements using Perl syntax. ```perl require 'names.pl'; sub main { startApplication("Elements"); tapObject(waitForObject($Names::elements_by_name_uitableviewcell)); tapObject(waitForObject($Names::argon_ar_uitableviewcell)); test::compare(waitForObjectExists($Names::noble_gases_uilabel)->text->stringValue, "Noble Gases"); tapObject(waitForObject($Names::name_uinavigationitembuttonview)); snooze(1); tapObject(waitForObject($Names::main_uinavigationitembuttonview)); tapObject(waitForObject($Names::search_uitableviewcell)); tapObject(waitForObject($Names::uisearchbartextfield), 113, 14); type(waitForObject($Names::uisearchbartextfield), "pluto"); tapObject(waitForObject($Names::search_uinavigationbutton)); test::compare(waitForObjectExists($Names::o94_plutonium_pu_uitableviewcell)->text->stringValue, "94: Plutonium (Pu)"); } ``` -------------------------------- ### Start Squish Application Source: https://doc.qt.io/squish/how-to-use-the-java-api.html Launches the specified application using its path. Ensure the SQUISH_PREFIX environment variable is set. ```tcl startApplication "$::env(SQUISH_PREFIX)/examples/java/paymentform_swt/PaymentFormSWT.jar" ``` -------------------------------- ### Get Object Properties in Tcl Source: https://doc.qt.io/squish/object-properties-function.html This Tcl example retrieves and logs all properties of a Squish object. The properties are stored in a Tcl array, which must be explicitly named and potentially reset. ```tcl set widget [waitForObject ":MyWidget"] object properties $widget properties foreach key [array names properties] { set value [toString $properties($key)] test log "$key = $value" } ``` -------------------------------- ### Start AUT and Verify Window Visibility (JavaScript) Source: https://doc.qt.io/squish/squish-for-macos-tutorials.html Initiates the AUT and checks if the main window is visible. Requires the OS.getenv("SQUISH_PREFIX") to be configured. ```javascript Given("addressbook application is running", function(context) { startApplication('"' + OS.getenv("SQUISH_PREFIX") + '/examples/mac/addressbook/SquishAddressBook"'); test.compare(waitForObjectExists(names.addressBookUntitledNSWindow).isVisible, 1); }); ``` -------------------------------- ### Example Script-Based Test Case in Python Source: https://doc.qt.io/squish/squish-for-java-bdd-tutorials.html This Python code demonstrates a basic test case for the Addressbook application, including starting the application, logging an action, and verifying the initial state. ```python def main(): startApplication("Addressbook") test.log("Create new addressbook") clickButton(waitForObject(names.new_ToolbarItem)) test.compare(waitForObjectExists(names.address_Book_Unnamed_Table).rowCount, 0) ``` -------------------------------- ### Tcl: Start Browser and Log Warning Source: https://doc.qt.io/squish/squish-for-web-tutorials-mbt.html Use this Tcl snippet to launch the AUT browser and log a warning for a missing step. Squish must be hooked to the AUT before execution. ```tcl mbt step "Create new address book" {} { invoke startBrowser "http://localhost:9090/AddressBook.html" test warning "TODO implement Create new address book" } ``` -------------------------------- ### Python Test Script Example Source: https://doc.qt.io/squish/squish-for-ios-tutorials.html A Python script demonstrating common Squish actions like starting an application, interacting with UI elements using tapObject and type, and comparing object properties. ```python import names def main(): startApplication("Elements") tapObject(waitForObject(names.elements_by_name_UITableViewCell)) tapObject(waitForObject(names.argon_Ar_UITableViewCell)) test.compare(waitForObjectExists(names.noble_Gases_UILabel).text.stringValue, "Noble Gases") tapObject(waitForObject(names.name_UINavigationItemButtonView)) snooze(1) tapObject(waitForObject(names.main_UINavigationItemButtonView)) tapObject(waitForObject(names.search_UITableViewCell)) tapObject(waitForObject(names.o_UISearchBarTextField), 113, 14) type(waitForObject(names.o_UISearchBarTextField), "pluto") tapObject(waitForObject(names.search_UINavigationButton)) test.compare(waitForObjectExists(names.o94_Plutonium_Pu_UITableViewCell).text.stringValue, "94: Plutonium (Pu)") ``` -------------------------------- ### Start Application Source: https://doc.qt.io/squish/applicationcontext-class.html Starts an application and returns a handle to its application context. Overloads allow specifying the host and port. ```APIDOC ## ApplicationContext startApplication(autName) ### Description Starts the application specified by `autName` and returns a handle to its application context. ### Method N/A (Function call) ### Parameters - **autName** (string) - Required - The name of the application to start. ### Response #### Success Response - **ApplicationContext** - A handle to the started application context. ``` ```APIDOC ## ApplicationContext startApplication(autName, host) ### Description Starts the application specified by `autName` on the given `host` and returns a handle to its application context. ### Method N/A (Function call) ### Parameters - **autName** (string) - Required - The name of the application to start. - **host** (string) - Required - The hostname or IP address where the application should be started. ### Response #### Success Response - **ApplicationContext** - A handle to the started application context. ``` ```APIDOC ## ApplicationContext startApplication(autName, host, port) ### Description Starts the application specified by `autName` on the given `host` and `port`, and returns a handle to its application context. ### Method N/A (Function call) ### Parameters - **autName** (string) - Required - The name of the application to start. - **host** (string) - Required - The hostname or IP address where the application should be started. - **port** (integer) - Required - The TCP port on which the application should listen. ### Response #### Success Response - **ApplicationContext** - A handle to the started application context. ``` -------------------------------- ### Execute JavaScript and Retrieve Style Property Source: https://doc.qt.io/squish/how-to-use-the-web-api.html Use the evalJS function to execute arbitrary JavaScript code in the browser's interpreter and retrieve the result. This example gets the 'display' style property of an element by its ID. ```python style_display = evalJS("var d = document.getElementById(" + "'busyDIV'); d ? d.style.display : ''") ``` ```javascript var style_display = evalJS("var d = document.getElementById(" + "'busyDIV'); d ? d.style.display : ''"); ``` ```perl my $style_display = evalJS("var d = document.getElementById(" . "'busyDIV'); d ? d.style.display : ''"); ``` ```ruby style_display = evalJS("var d = document.getElementById(" + "'busyDIV'); d ? d.style.display : ''") ``` ```tcl set style_display [invoke evalJS "var d = document.getElementById(\ 'busyDIV'); d ? d.style.display : ''"] ``` -------------------------------- ### Regular Expression Matching for Caption Source: https://doc.qt.io/squish/improving-object-identification.html Regular expression matching allows for sophisticated pattern recognition in properties. This example matches a caption starting with 'UsefulApp v' followed by version numbers and a '.dat' suffix, case-insensitively. ```Python {'caption': RegularExpression('UsefulApp v[1-9].[0-9] - ?*.[dD][aA][tT]'), 'type': 'MainWindow'} ```