Skip to content

How to connect qt widgets app with selenium using Python #76

Open
@naresha911

Description

@naresha911

Virtual machine
Ubuntu : 22.04.1

  1. Successfully installed selenium and all required packages. Verified basic selenium test case to launch firefox browser (without qtwebdriver).
  2. Successfully built qtwebdriver using these instructions https://github.com/cisco-open-source/qtwebdriver/wiki/Build-And-Run.
  3. Added path to out/dist/desktop/release/bin/ in my Ubuntu PATH
  4. Modified Qt widgets mainwidow sources as per the instructions https://github.com/cisco-open-source/qtwebdriver/wiki/Use-QtWebDriver-to-run-your-application
  5. The qtwidgets application has successfully build and is running. I get an error in console though:
    [SEVR]: Root './web' does not exist!

Now to verify one simple case with selenium in Python, I used below code:

from selenium import webdriver
capability = webdriver.DesiredCapabilities.FIREFOX
capability['browserStartWindow']='*'
driver = webdriver.Remote(
    desired_capabilities=capability,
    command_executor="http://127.0.0.1:9517"

)
print("Native page source:", driver.getPageSource());
elt = driver.findElement(By.xpath("//QTextEdit"));

I get following errors:

/home/npp/Qt_5_15_2/Examples/Qt-5.15.2/widgets/mainwindows/application/testrun.py:32: DeprecationWarning: desired_capabilities has been deprecated, please pass in an Options object with options kwarg

  driver = webdriver.Remote(

Traceback (most recent call last):

  File "/home/npp/Qt_5_15_2/Examples/Qt-5.15.2/widgets/mainwindows/application/testrun.py", line 32, in <module>

    driver = webdriver.Remote(

  File "/home/npp/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 288, in __init__

    self.start_session(capabilities, browser_profile)

  File "/home/npp/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 381, in start_session

    response = self.execute(Command.NEW_SESSION, parameters)

  File "/home/npp/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 444, in execute

    self.error_handler.check_response(response)

  File "/home/npp/.local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 249, in check_response

    raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: Missing or invalid 'desiredCapabilities'

Am I missing any libs? I kindly request someone to guide me here. I just start learning selenium. I'm basically a qt developer.
We would like to use selenium for testing our qt applications.

Thank you

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