2011-05-03 57 views
0

我想在Windows 7中有正在一步,我通过运行安装WWW::HTMLUnit无法安装WWW ::中的HtmlUnit Windows中

  1. 安装内嵌:: Java的0.53
  2. 安装WWW :: HTMLUnit 0.15

在第2步,在nmake之后,我输入nmake测试到测试模块,但失败了。下面是输出:

C:\nmake test 

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01 
Copyright (C) Microsoft Corporation. All rights reserved. 

C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib\lib', 'blib\arch')" t/*.t 
t/00_basic........... 
t/00_basic...........NOK 1/1# Failed test 'use WWW::HtmlUnit;' 
# at t/00_basic.t line 9. 
#  Tried to use 'WWW::HtmlUnit'. 
#  Error: Class com.gargoylesoftware.htmlunit.WebClient not found at C:/Perl/site/lib/Inline/Java.pm line 619 
# BEGIN failed--compilation aborted at (eval 4) line 2, <GEN7> line 4. 
# Looks like you failed 1 test of 1. 
t/00_basic...........dubious 
     Test returned status 1 (wstat 256, 0x100) 
DIED. FAILED test 1 
     Failed 1/1 tests, 0.00% okay 
t/01_hello...........Class com.gargoylesoftware.htmlunit.WebClient not found at C:/Perl/site/lib/Inline/Java.pm line 619 
BEGIN failed--compilation aborted at t/01_hello.t line 4, <GEN7> line 4. 
t/01_hello...........dubious 
     Test returned status 26 (wstat 6656, 0x1a00) 
t/02_hello_sweet.....dubious 
     Test returned status 19 (wstat 4864, 0x1300) 
t/03_clickhandler....Class com.gargoylesoftware.htmlunit.WebClient not found at C:/Perl/site/lib/Inline/Java.pm line 619 
BEGIN failed--compilation aborted at t/03_clickhandler.t line 6, <GEN7> line 4. 
t/03_clickhandler....dubious 
     Test returned status 29 (wstat 7424, 0x1d00) 
DIED. FAILED tests 1-8 
     Failed 8/8 tests, 0.00% okay 
Failed Test   Stat Wstat Total Fail List of Failed 
------------------------------------------------------------------------------- 
t/00_basic.t   1 256  1 1 1 
t/01_hello.t   26 6656 ?? ?? ?? 
t/02_hello_sweet.t 19 4864 ?? ?? ?? 
t/03_clickhandler.t 29 7424  8 16 1-8 
Failed 4/4 test scripts. 9/9 subtests failed. 
Files=4, Tests=9, 3 wallclock secs (0.00 cusr + 0.00 csys = 0.00 CPU) 
Failed 4/4 test programs. 9/9 subtests failed. 
NMAKE : fatal error U1077: 'C:\Perl\bin\perl.exe' : return code '0x1d' 
Stop. 

从上面的日志,我可以看到:

class Error: com.gargoylesoftware.htmlunit.WebClient could not be found.

我不知道,我错过了什么。 任何帮助,将不胜感激。

谢谢。 Minh。

+0

是的,我将JAVA_HOME设置为“C:\ Program Files(x86)\ Java \ jdk1.6.0_25”作为安装JDK的位置。顺便说一句,我可以运行一些Java内联代码(使用Inline :: Java) – 2011-05-03 21:26:27

+0

我尝试安装它,将CLASSPATH设置为HTMLUnit库中的* .jar文件。我编写了一些代码并得到了结果“错误:未在C:/Perl/site/lib/Inline/Java.pm第619行找到类com.gargoylesoftware.htmlunit.WebClient”。 – 2011-05-03 21:34:09

+0

如果您的需要是在网页上测试Javascript,请尝试WWW :: Scripter :: Plugin :: JavaScript或WWW :: Selenium。硒使用真正的网络浏览器会给你最真实的结果。 – Schwern 2011-05-04 00:55:10

回答

1

我找到了。 Unix和Windows系统的路径有所不同。 Unix使用':'作为分隔符,但Windows使用';'。所以我所做的是打开HTMLUnit.pm并将':'全部更改为';'。 用的HtmlUnit版本0.15。我跟下面这些线路的变化: 78号线:

return join ';', map { "$jar_path/$_" } qw(# return join ':', map { "$jar_path/$_" } qw(

行127:

$custom_jars = join(';', @{$parameters{'jars'}}); # $custom_jars = join(':', @{$parameters{'jars'}}); 

行148:

CLASSPATH => collect_default_jars() . ";" . $custom_jars, # CLASSPATH => collect_default_jars() . ":" . $custom_jars, 

它就像一个魔术。

1

(它不会让我在现有的答案评论)

我看到你对答案“:” VS“;”。我将尝试在下一个WWW :: HtmlUnit发行版中包含修复程序(我是perl绑定的作者)。