【问题标题】:Winium driver throws error while trying to quitWinium 驱动程序在尝试退出时抛出错误
【发布时间】:2019-04-22 14:30:02
【问题描述】:

我正在尝试使用 Winium-Eclipse 自动化基于 Windows 的应用程序。 我的代码已成功执行,但在最后一行“driver.quit()”抛出错误。 如果我评论这一行,则没有发现更多错误。 执行后如何退出驱动?

错误是 线程“main”org.openqa.selenium.WebDriverException 中的异常:进程已退出,因此请求的信息不可用。 (警告:服务器未提供任何堆栈跟踪信息)

驱动信息:org.openqa.selenium.winium.WiniumDriver

我附上了一个示例代码供您参考,它会引发相同的错误。

package calc2;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;

public class TestCalc2 
{
	public static void main(String args[]) throws MalformedURLException, InterruptedException
	{
		DesktopOptions options = new DesktopOptions();
		options.setApplicationPath("C:\\Windows\\System32\\calc.exe");
		WiniumDriver driver = new WiniumDriver(new URL("http://localhost:9999"),options);
		Thread.sleep(3000);
		driver.findElementById("num8Button").click();
		driver.findElementById("plusButton").click();
		driver.findElementById("num9Button").click();
		driver.findElementById("equalButton").click();
		String output = driver.findElement(By.id("CalculatorResults")).getAttribute("Name");
		System.out.println("Result:"+output);
		driver.findElementById("Close").click();
		driver.quit();		
	}
}

【问题讨论】:

    标签: selenium automation automated-tests winium


    【解决方案1】:

    由于您已经通过单击关闭按钮关闭了应用程序,因此驱动程序无法退出。 尝试评论这一行 driver.findElementById("Close").click();

    【讨论】:

    • 你好,Vijay,我按照你说的试过了。评论关闭应用程序命令仍然会抛出错误“org.openqa.selenium.WebDriverException:进程已退出,因此请求的信息不可用。(警告:服务器未提供任何堆栈跟踪信息)”
    • 您好,Driver Exited 错误只会在驱动程序持有的应用程序不再可用或不在焦点上时出现。我曾经遇到过这个错误,对我来说,删除 close button click 起作用了。不知道是不是焦点问题。尝试 driver.quit 而不打印输出。
    猜你喜欢
    • 2013-10-06
    • 2017-06-06
    • 2014-09-01
    • 2012-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    • 1970-01-01
    相关资源
    最近更新 更多