I'm working on end to end test case automation.

  1. First 5 test step need to check on web. [Selenium Web driver]
  2. Next 3 steps need to validate in windows desktop apps.[Winapp driver]
  3. Again need to do the verification in Web.

For web we are using Selenium Web driver, For windows desktop using Winappdriver. switching driver based on the requirement is possible or any other optimal approaches available

Kindly let us know that will be helpful.

2 Answers 2


There's nothing wrong with using two drivers, just lookout for things like timeouts with Selenium Webdriver that have a default timeout (after some seconds of no requests to the Selenium it shuts down the session).

var webDriver = new ChromeDriver();
var winDriver = new WinAppDriver();
webDriver.url = "https://sqa.stackexchange.com";
winDriver.Foo.bar(); // potential timeout

Yes, it's possible to switch between Selenium WebDriver and WinAppDriver within the same test script based on your requirements. This approach is known as "cross-platform" or "cross-environment" testing, where you automate test scenarios that involve multiple platforms or technologies.

Here's a general approach you can follow:

python code

from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from appium import webdriver as appium_driver import time

Function to initialize the Selenium WebDriver

def initialize_webdriver(): # You can customize the browser and other options based on your needs driver = webdriver.Chrome() return driver

Function to initialize the WinAppDriver

def initialize_winappdriver(): # Configure the Appium capabilities for your Windows application desired_caps = { "app": "YourWindowsAppPath\YourWindowsApp.exe", # Add other capabilities as needed } driver = appium_driver.Remote( command_executor="", # Appium server address desired_capabilities=desired_caps ) return driver

Function to perform web-specific actions

def perform_web_actions(driver): # Example web actions driver.get("https://yourwebapp.com") # Perform additional web actions as needed WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "yourWebElement"))).click()

Function to perform Windows app-specific actions

def perform_winapp_actions(driver): # Example Windows app actions # Perform actions specific to your Windows application time.sleep(5) # Add appropriate waits for element visibility and interaction # Example: driver.find_element_by_name("YourWindowsElement").click()

Initialize and perform actions

try: # Initialize the Selenium WebDriver for web actions web_driver = initialize_webdriver()

# Perform the first 5 web steps

# Initialize the WinAppDriver for Windows app actions
winapp_driver = initialize_winappdriver()

# Perform the next 3 Windows app steps

# Switch back to the Selenium WebDriver for the remaining web steps

finally: # Close both drivers to release resources if web_driver: web_driver.quit() if winapp_driver: winapp_driver.quit()

In this example, the script initializes a Selenium WebDriver for web interactions, performs some web-specific actions, then initializes a WinAppDriver for Windows app interactions, performs some Windows app-specific actions, and finally switches back to the Selenium WebDriver for additional web actions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.