当前位置: 首页 > 面试题库 >

通过Java和Selenium启动Internet Explorer时出现“ OsProcess checkForError:CreateProcess错误= 193,%1不是有效的Win32应用程序”

严峰
2023-03-14
问题内容

我正在使用Eclipse(Java)中的Selenium驱动程序,我想创建一个驱动程序来测试Internet
Explorer页面,并且不断收到此错误消息,我的驱动程序可以在Firefox和chrome上正常工作,但是在资源管理器中我无法进行任何测试

System.setProperty("webdriver.ie.driver", "C:\\Users\\emorales\\Documents\\MicrosoftWebDriver.exe");
//set webdriver to explorer  test
WebDriver driver = new InternetExplorerDriver();

//metodo para obtener url
driver.get("http://google.com");

System.out.println(driver.getTitle());

这是我的错误堆栈跟踪:

Jul 31, 2018 1:41:12 PM org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "C:\Users\emorales\Documents\MicrosoftWebDriver.exe" (in directory "."): CreateProcess error=193, %1 is not a valid Win32 application)
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:14.902Z'
System info: host: 'PCPSE0015', ip: '10.1.0.151', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '10.0.2'
Driver info: driver.version: InternetExplorerDriver
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:193)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:179)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
    at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:221)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:213)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:150)
    at TEST3.main(TEST3.java:10)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:13816/status] to be available after 20002 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:188)
    ... 8 more
Caused by: java.util.concurrent.TimeoutException
    at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
    ... 9 more

问题答案:

此错误消息…

org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "C:\Users\emorales\Documents\MicrosoftWebDriver.exe" (in directory "."): CreateProcess error=193, %1 is not a valid Win32 application)

…表示 底层操作系统 无法启动/产生新的 WebBrowsering 会话,即 Internet Explorer浏览器 会话。

根据您的代码试用,您尝试将 WebDriver 实例(即 driver) 强制转换*
InternetExplorerDriver(),因此在这一行中,System.setProperty()您需要提供相应
IEDriverServer 二进制文件的 绝对路径 (而不是 MicrosoftWebDriver.exe )。

* __

您可以从索引页面下载relevent IEDriverServer
二进制版本,并在代码中提及为:

System.setProperty("webdriver.ie.driver", "C:\\path\\to\\IEDriverServer.exe");
//set webdriver to explorer  test
WebDriver driver = new InternetExplorerDriver();

//metodo para obtener url
driver.get("http://google.com");

System.out.println(driver.getTitle());


 类似资料:
  • 问题内容: 我有一个新的Rails应用程序,该应用程序是在Windows 7下通过进入目录并键入“ rails newapp”创建的。创建过程很好,当我访问根页面时,一切都很好。但是,当我尝试访问将访问数据库的页面时,得到以下信息: 在developer.log中。Mysql在我的机器上运行良好,并且我在其他目录中的其他应用程序中也正在运行,仅此一项是行不通的。有什么想法吗? 问题答案: 这是对我

  • 问题内容: 在maven中运行exec-npm-update时,出现以下错误CreateProcess error = 193,%1不是有效的Win32应用程序-> [帮助1] 以下是pom文件中的代码段。 问题答案: 发生此问题的原因是我使用的角度版本为1.5。 将可执行文件从npm更改为npm.cmd可以解决问题!

  • 问题内容: 我试图从带有子进程的python解释器中调用python文件“ hello.py”。但我无法解决此错误。[Python 3.4.1]。 除了使用子过程之外,还有没有其他方法可以“使用参数调用python脚本”?提前致谢。 问题答案: 错误非常明显。该文件不是可执行文件。您需要指定可执行文件: 您需要在搜索路径上可见,或者可以将完整路径传递给运行调用脚本的可执行文件:

  • 我安装了 pip安装wordcloud 然后我导入了 我得到了这个错误:

  • 问题内容: 我正在编写一个GUI前端,在执行一堆验证后将执行一系列已经存在的vbscript .wsf文件。 我的问题是,当我尝试执行.wsf文件时,出现错误 从命令行运行它们工作正常 我尝试了几种不同的选项,如call,os.system等。但是所有这些都导致相同的Win32错误。 有任何想法吗? 问题答案: 如警告所述,不是应用程序。它是通过作为参数传递给脚本引擎而运行的脚本。您可能需要改为调

  • 本文向大家介绍java.lang.UnsatisfiedLinkError: %1 不是有效的Win32应用程序错误解决,包括了java.lang.UnsatisfiedLinkError: %1 不是有效的Win32应用程序错误解决的使用技巧和注意事项,需要的朋友参考一下 发现问题 最近工作中利用JNA 调用 dll 库时保错,错误如下: 我环境是 64 位 win7. java.lang.Un