Using QtWebDriver to create Qt's automated tests

我只是一个虾纸丫 提交于 2021-02-08 03:59:52

问题


I would like to create automated tests for a Qt's app with selenium + QtWebDriver.

I have read the QtWebDriver's wiki, and some questions on stackoverflow like this one

However, I'm still not able to use QtWebDriver. I don't understand how to link selenium and QtWebDriver together. there are a lot of questions that I can't answer.

How can I use Python to create automated tests for my own Qt's App based on selenium + QtWebDriver ?

How can I link my Qt's app with selenium + QtWebDriver ?

What is the next step after running webDriver.exe ?

I'd be very grateful if someone could help me or send me a tutorial with an example.

Thanks in advance!


回答1:


How can I use Python to create automated tests for my own Qt's App based on selenium + QtWebDriver ?

Once the WebDrIver is running with your application you can test it in python like any selenium test, e.g:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Remote(
    desired_capabilities=webdriver.DesiredCapabilities.FIREFOX,
    command_executor='http://ip_of_webdriver:9517'
)
driver.get('http://example.com/exampleform.html')

# select input
form = driver.find_elements_by_xpath("//input[@name='lastname']")[0]

# PRESS ENTER
form.send_keys(Keys.ENTER)
# etc...

How can I link my Qt's app with selenium + QtWebDriver ?

  • From Selenium just use the RemoteWebDriver
  • To link your application with QtWebDriver:
    • include the libs and headers of QtWebDrivcer in your application's build environment. (You can rebuild WD from source for your platform if needed)
    • modify your application's main so that it starts the QtWebdriver
    • rebuild
    • example and instructions here: https://github.com/cisco-open-source/qtwebdriver/wiki/Build-And-Run#to-build-and-run-your-own-binary
    • Once this is done, start your application
    • Then using Selenium you will be able to connect to Webdriver and automate your application
    • If you are using a native applcation, have a look here: https://github.com/cisco-open-source/qtwebdriver/wiki/Hybridity-And-View-Management#hybrid-uis, in order to see how WebDriver navigates native/hybrid UIs


来源:https://stackoverflow.com/questions/38118506/using-qtwebdriver-to-create-qts-automated-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!