首页 > 解决方案 > 使用 Winiumdriver 的 WebDriver 异常

问题描述

我已经开始学习 Winium 工具了。使用以下代码运行时:

public class CalcDemo {

    public static void main(String[] args) throws MalformedURLException {

        DesktopOptions options=new DesktopOptions();
        options.setApplicationPath("‪C:\\Windows\\System32\\notepad.exe");
        WiniumDriver driver=new WiniumDriver(new URL("http://localhost:9999"), options);
        driver.findElementByClassName("Edit").sendKeys("This is sample test");
        driver.close();
    }
}

我收到以下错误:

"org.openqa.selenium.WebDriverException: The given path's format is not supported"

谁能帮我吗。

谢谢。

标签: javaselenium-webdriverautomationwinium

解决方案


我认为您需要在尝试访问 Edit 类之前找到该窗口。

这是我的 C# 示例:

        var dc = new DesiredCapabilities();
        dc.SetCapability("app", @"C:/windows/system32/Notepad.exe");
        var driver = new RemoteWebDriver(new Uri("http://localhost:9999"), dc);

        var window = driver.FindElementByClassName("Notepad");
        var edit = window.FindElement(By.Name("Text Editor"));

推荐阅读