Skip to content

Unable to Locate Qt Widgets via Locators in Qt WebDriver #77

Open
@vivek-vadher

Description

@vivek-vadher

Steps to Reproduce

  1. Built and launched the Qt WebDriver example application (or custom Qt application) as described in the documentation.
  2. Started the application with WebDriver enabled:

./app.app/Contents/MacOS/app --webdriver=9517

  1. Verified that the application is running and WebDriver is active (http://localhost:9517/status returns OK).
  2. Used the following Selenium script to locate elements:
from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Remote(
    command_executor="http://localhost:9517",
    options=webdriver.ChromeOptions()
)

# Wait for application initialization
time.sleep(5)

# Try to locate a button with ID 'button5'
try:
    button_5 = driver.find_element(By.ID, "button5")
    print("Button found:", button_5)
except Exception as e:
    print("Error locating button:", e)

# Debug: Print all available elements
elements = driver.find_elements(By.XPATH, "//*")
for element in elements:
    print(f"Tag: {element.tag_name}, ID: {element.get_attribute('id')}")

driver.quit()

The script only returns:

Number of elements found: 3
Tag: html, ID: 
Tag: head, ID: 
Tag: body, ID: 

Expected Behavior

All interactive Qt widgets (e.g., buttons, labels) should be exposed with their corresponding objectName attributes as id in the WebDriver.

Observed Behavior
• Only basic HTML tags (html, head, and body) are exposed.
• No id attributes for the buttons, labels, or other widgets, even when the objectName properties have been set in the Qt application code.

Environment
• Operating System: macOS (M1 Architecture)
• Qt Version: 6.7.3 (installed via Homebrew)
• Qt WebDriver Version: Latest Dockerized version
• Browser: Chrome (Version 132.0.6834.84)
• ChromeDriver: 132.0.6834.83
• Selenium Version: 4.27.1
• Python Version: 3.12

Logs and Debugging Details
1. From http://localhost:9517/inspector:
• No widgets are visible; only html, head, and body tags are displayed.
2. Debugging Output from Selenium Script

3.	Application log (started with --verbose):
•	No errors or warnings related to WebDriver initialization.

Additional Context
• The objectName properties have been explicitly set in the Qt application for each widget (e.g., button5, buttonPlus, display).
• Verified the application works as expected when run normally without WebDriver.
• The issue occurs with both custom applications and example applications using Qt WebDriver.

Could you please help investigate why widgets are not being exposed through Qt WebDriver? Is there additional configuration required for Qt WebDriver to properly expose widgets? If this is a known limitation, are there any workarounds?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions