问题描述
webdriver类[b]:packagedemonsFirstTestNG;importorg.openqa.selenium.By;importjava.lang.Exception;importorg.openqa.selenium.*;importorg.openqa.selenium.htmlunit.*;importorg.openqa.selenium.ie.InternetExplorerDriver;importorg.openqa.selenium.support.ui.ExpectedCondition;importorg.openqa.selenium.support.ui.WebDriverWait;//importorg.openqa.selenium.JavascriptExecutor;importorg.openqa.selenium.remote.DesiredCapabilities;importorg.openqa.selenium.remote.RemoteWebDriver;//importorg.openqa.selenium.htmlunit.*;importorg.openqa.selenium.firefox.FirefoxDriver;importorg.openqa.selenium.support.ui.*;importjava.net.*;importjava.io.*;importorg.apache.logging.log4j.*;publicclassTestbaiduSigle{StringbaseUrl;WebDriverdriver;privateLoggerloger=LogManager.getLogger(TestbaiduSigle.class.getName());/***@paramargs*/publicTestbaiduSigle(){loger.info("startopenURL....");baseUrl="http://www.baidu.com/";System.setProperty("webdriver.ie.driver","G:\Auto_project\java\lib\IEDriverServer.exe");DesiredCapabilitiescapabilities=DesiredCapabilities.internetExplorer();capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);System.out.println("driverstart");driver=newInternetExplorerDriver(capabilities);}publicvoidtestexe(){System.out.println("openURLstart");driver.get(baseUrl+"/");//driver.wait(3000);System.out.println("start");newWebDriverWait(driver,20).until(newExpectedCondition<WebElement>(){@OverridepublicWebElementapply(WebDriverd){//TODOAuto-generatedmethodstubreturnd.findElement(By.id("kw"));}}).sendKeys("testuser");System.out.println("end");driver.findElement(By.id("su")).click();}publicstaticvoidmain(String[]args){TestbaiduSigletw2=newTestbaiduSigle();try{tw2.testexe();System.out.println("itisok");}catch(Exceptione){System.out.println(e.toString());}}}[b]ant运行报错:G:Auto_projectantTestNGWebdriverStudy>antBuildfile:G:Auto_projectantTestNGWebdriverStudybuild.xmlclean:[delete]Deleting:G:Auto_projectantTestNGWebdriverStudysrcdemonsFirstTestNGTestbaiduSigle.java[delete]DeletingdirectoryG:Auto_projectantTestNGWebdriverStudyclasses[delete]DeletingdirectoryG:Auto_projectantTestNGWebdriverStudylibinit:[copy]Copying1filetoG:Auto_projectantTestNGWebdriverStudysrcdemonsFirstTestNG[mkdir]Createddir:G:Auto_projectantTestNGWebdriverStudyclasses[mkdir]Createddir:G:Auto_projectantTestNGWebdriverStudylibcompile:[javac]Compiling1sourcefiletoG:Auto_projectantTestNGWebdriverStudyclasses[javac]G:Auto_projectantTestNGWebdriverStudysrcdemonsFirstTestNGTestbaiduSigle.java:39:找不到符号[javac]符号:变量INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS[javac]位置:类org.openqa.selenium.ie.InternetExplorerDriver[javac]capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);[javac]^[javac]1错误BUILDFAILEDG:Auto_projectantTestNGWebdriverStudybuild.xml:30:Compilefailed;seethecompilererroroutputfordetails.Totaltime:1secondbuild.xml文件配置:<?xmlversion="1.0"encoding="gbk"?><projectname="TestNGWebdriverStudy"default="run"basedir="."><propertyname="src"value="src"/><propertyname="dest"value="classes"/><propertyname="lib"value="lib"></property><propertyname="third_lib"value="../../java/lib"></property><!--propertyname="hello_jar"value="Helloword.jar"></property--><propertyname="Tweb_jar"value="TestNGWebdriverStudy.jar"></property><!--导入第三方JAR包<pathelementpath="${third_lib}/selenium-server-standalone-2.40.0.jar"/><libfilesetdir="${third_lib}"includes="*.*"/>--><pathid="lib_classpath"><filesetdir="${third_lib}"><includename="*.jar"/></fileset><pathelementlocation="${dest}"/></path><!--初始化之前执行删除操作--><targetname="init"depends="clean"><copyfile="../../java/TestNGWebdriverStudy/src/demonsFirstTestNG/TestbaiduSigle.java"todir="src/demonsFirstTestNG"></copy><mkdirdir="${dest}"/><mkdirdir="${lib}"/></target><!--编译生成class文件--><targetname="compile"depends="init"><javacsrcdir="${src}"destdir="${dest}"classpathref="lib_classpath"includeantruntime="off"debug="on"></javac><!--classpathrefid="lib_classpath"/--></target><!--将编译后的class文件打包--><targetname="build"depends="compile"><mkdirdir="${lib}"/><jarjarfile="${lib}/${Tweb_jar}"basedir="${dest}"></jar></target><!--删除--><targetname="copyF"depends="build"><copyfile="log4j2.xml"todir="${dest}"></copy><!--是copy文件--></target><targetname="run"depends="copyF"><!--javaclassname="demonsFirstTestNG.Helloword"jar="${third_lib}"classpath="${lib}/${hello_jar}"><classpathrefid="lib_classpath"/></java--><javaclassname="demonsFirstTestNG.TestbaiduSigle"classpath="${lib}/${Tweb_jar}"><classpathrefid="lib_classpath"/></java></target><!--删除--><targetname="clean"><deletefile="./src/demonsFirstTestNG/TestbaiduSigle.java"></delete><deletedr="${dest}"></delete><deletedir="${lib}"></delete><!--是dir删除目录,不是file删除文件--></target></project>eclipse运行结果21:50:14.048[main]INFOdemonsFirstTestNG.TestbaiduSigle-startopenURL....driverstartStartedInternetExplorerDriverserver(32-bit)2.25.2.0Listeningonport129762014-7-1921:50:16org.apache.http.impl.client.DefaultRequestDirectortryExecute信息:I/Oexception(java.net.SocketException)caughtwhenprocessingrequest:Softwarecausedconnectionabort:recvfailed2014-7-1921:50:16org.apache.http.impl.client.DefaultRequestDirectortryExecute信息:RetryingrequestopenURLstartstartenditisok求助问题1.为啥在esclipse都可以正常编译运行,能正常运行完成,有如上运行结果报错信息2.同样的java文件在ant环境下编译就无法编译通过,ant无法编译InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,请那位高手帮助一下。