I\'m trying to automate a Windows application GUI using Winium. The app is using both WPF windows and \"Chrome Legacy Window\" (Chromium) windows.
I\'m using the too
I added the "remote-debugging-port=XXXX" to my CEF (Chromium Embedded Framework) command: https://blog.chromium.org/2011/05/remote-debugging-with-chrome-developer.html This allowed me to see and manage my app's CEF windows through localhost:XXXX.
I used both Winium and Selenium to test my app. Winium for all my WPF windows and selenium for all my CEF windows. My GUI test starts with Winium Driver to open my app and navigate WPF windows. Each time I need to debug a CEF window, I'm opening a Chrome Driver using selenium with the "remote-debugging-port" argument, which allows me to click elements inside that window. When I'm finish with this chromium window I'm closing the selenium driver and continues with Winium.
Selenium is a portable framework for testing and automating web applications. Winium is a Selenium-based tool for testing and automating desktop applications on Windows. In order to use these modules inside IntelliJ IDEA project, follow these steps:
Now all Selenium and Winium imports should work. For example:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;
import org.openqa.selenium.winium.WiniumDriverService;
Follow these steps:
c:\temp\ cef_binary_3.2171.1979_windows32_client\ Release\ cefclient.exe (and other files) chromedriver.exe Example.java selenium-server-standalone-2.44.0.jar
For more information you can read this wiki: https://bitbucket.org/chromiumembedded/cef/wiki/UsingChromeDriver.md
Follow these steps:
Start a winium driver and open your app:
DesktopOptions desktopOption = new DesktopOptions();
desktopOption.setApplicationPath("Path_to_your_app.exe");
File drivePath = new File("C:\\temp\\Winium.Desktop.Driver.exe");
WiniumDriverService service = new WiniumDriverService.Builder().usingDriverExecutable(drivePath).usingPort(9999).withVerbose(true).withSilent(false).buildDesktopService();
service.start();
WiniumDriver winiumDriver = WiniumDriver(service, desktopOption);
Navigate and test WPF windows using winium. For example:
winiumDriver.findElement(By.id("someElementID")).click();
Create a ChromeOptions object which holds all needed selenium information such as chromium client and remote debugging port. Make sure to change the "XXXX" port to your remote debugging port.
System.setProperty("webdriver.chrome.driver", "c:/temp/chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("c:/temp/cef_binary_76.1.13+gf19c584+chromium-76.0.3809.132_windows64_client/Release/cefclient.exe");
chromeOptions.addArguments("remote-debugging-port=XXXX");
Open a chrome driver (selenium) using the chrome options object.
WebDriver seleniumDriver = ChromeDriver(chromeOptions);
Use element inside the chromium windows. For example:
seleniumWait.until(ExpectedConditions.visibilityOfElementLocated(By.className("someButtonClassName")));
seleniumDriver.findElement(By.className("someButtonClassName")).click();
When you're done with the CEF window, close selenium driver and continue with the winium driver:
seleniumDriver.quit();
winiumDriver.findElement(By.id("someElementID")).click();
Close main winium driver:
winiumDriver.quit();