51Testing软件测试论坛

标题: com.thoughtworks.selenium.SeleniumException: Not found [打印本页]

作者: yimaotao    时间: 2010-5-17 16:59
标题: com.thoughtworks.selenium.SeleniumException: Not found
拜托大家指点!!!
以下是我在用 selenium+testng时出现的错误:

com.thoughtworks.selenium.SeleniumException: Not found
        at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
        at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:168)
        at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:104)
        at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:86)
        at com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:335)
        at swpu.testSwpu(swpu.java:15)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:643)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:559)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:723)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1027)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:137)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:121)
        at org.testng.TestRunner.runWorkers(TestRunner.java:953)
        at org.testng.TestRunner.privateRun(TestRunner.java:633)
        at org.testng.TestRunner.run(TestRunner.java:505)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:316)
        at org.testng.SuiteRunner.run(SuiteRunner.java:195)
        at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:903)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:872)
        at org.testng.TestNG.run(TestNG.java:780)
        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:75)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:127)
作者: 小米啊    时间: 2010-5-17 17:00
测试类,你可以拿出来看下否
作者: yimaotao    时间: 2010-5-17 17:02
标题: 测试类
import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import java.util.regex.Pattern;
import com.thoughtworks.selenium.HttpCommandProcessor;
import com.thoughtworks.selenium.DefaultSelenium;


//import com.thoughtworks.selenium.SeleneseTestBase;
//extends SeleneseTestNgHelper
public class swpu extends SeleneseTestNgHelper{
        public Selenium selenium = new DefaultSelenium("localhost", 8080, "*firefox", "http://www.swpu.edu.cn");  
        @Test public void testSwpu() throws Exception {
                selenium.open("/");
                //selenium.clickAt("//div[@id='sasFlashFocus27']/embed[@id='27']", "");//媒体模块
                //selenium.click("//div[@id='imglinkone']/a[1]/img");//主页的  学生世界
                clickAndSelectModalDialog("//div[@id='imglinkone']/a[1]/img");
                selenium.mouseMoveAt("//div[@id='menudiv']/ul/li[1]/a", "");//学生世界页面
                selenium.click("link=入学指南");
                selenium.wait(300000000);
                //HttpCommandProcessor commandProcessor=new HttpCommandProcessor(null, 0, null, null);
               
                //commandProcessor.executeCommandOnServlet(arg0);
               
        }
        public void clickAndSelectModalDialog(String locator){   
                clickForModalDialog(locator);
                //selenium.selectWindow("name=modal");   
        }   
       
        private void  clickForModalDialog(String locator){   
                String overrideShowModalDialogJs="if(selenium.browserbot.getCurrentWindow().showModalDialog){";   
                 
                overrideShowModalDialogJs += "selenium.browserbot.getCurrentWindow().showModalDialog = function( sURL, vArguments, sFeatures)";   
                 
                overrideShowModalDialogJs +="selenium.browserbot.getCurrentWindow().open(sURL, 'modal', sFeatures);";   

                overrideShowModalDialogJs += "};}";   
                //showModalDialog方法进行覆盖   
                selenium.getEval(overrideShowModalDialogJs);   
                selenium.openWindow(locator,"modal");   
                selenium.waitForPopUp("modal","15000");   
                selenium.selectWindow("modal");
        }  
        public void  acceptModalValue(String locator,String[] values){  
            String overrideShowModalDialogJs="if(selenium.browserbot.getCurrentWindow().showModalDialog(){";  
                     
            overrideShowModalDialogJs += "selenium.browserbot.getCurrentWindow().showModalDialog = function( sURL, vArguments, sFeatures)";  
                     
                overrideShowModalDialogJs +="{ "+generateModalDialogReturnObject(values)+"return temp";  
                     
                overrideShowModalDialogJs += "};}";  
                //showModalDialog方法进行覆盖  
                selenium.getEval(overrideShowModalDialogJs);  
            selenium.click(locator);  
        }  
                    
        private String  generateModalDialogReturnObject (String[] values){  
            StringBuffer returnObject=new StringBuffer();  
                returnObject.append("var temp=new Array();");  
                for(int i=0;i<values.length;i++){
                        returnObject.append("temp["+i+"]='"+values+"';");  
                }  
                return returnObject.toString();
  
    }
作者: 小米啊    时间: 2010-5-17 17:11
你打断点执行,看下是哪行出错了呢?
作者: yimaotao    时间: 2010-5-18 14:29
我试了试下面的代码:

import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import java.util.regex.Pattern;

public class sample {
        Selenium selenium = new DefaultSelenium("localhost", 8080, "*firefox", "http://www.swpu.edu.cn");  
        @Test public void testUntitled() throws Exception {
                selenium.open("/");
                selenium.click("link=软件学院第三届董事会第一次会议召开");
                selenium.click("link=软件学院第三届董事会第一次会议召开");
                selenium.waitForPageToLoad("30000");
                selenium.click("link=首页");
                selenium.waitForPageToLoad("30000");
        }
}


我在selenium.click("link=软件学院第三届董事会第一次会议召开");处打的断电,,我还没有调试selenium.click("link=软件学院第三届董事会第一次会议召开");的时候就出现了下面的错误

[Parser] Running:
  C:\Documents and Settings\pliu\Local Settings\Temp\testng-eclipse\testng-customsuite.xml

FAILED: testUntitled
com.thoughtworks.selenium.SeleniumException: Not found
        at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
        at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:168)
        at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:104)
        at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:86)
        at com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:335)
        at sample.testUntitled(sample.java:10)
... Removed 22 stack frames

===============================================
    sample
    Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
selenium_Solutions
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[org.testng.internal.PoolService] Shutting down poolservice org.testng.internal.PoolService@1904e0d terminated:false

我觉得是执行selenium.open("/")的时候出错了,可是为什么呢?
作者: yimaotao    时间: 2010-5-18 14:31
是我下载的selenium包有问题么?
作者: 小米啊    时间: 2010-5-18 22:21
你要加一个selenium.start();
作者: SZFrank2007    时间: 2010-5-20 14:58
selenium.click("link=软件学院第三届董事会第一次会议召开");
    selenium.click("link=软件学院第三届董事会第一次会议召开");   这连个连接重合了,第一次连接后第二次还是连接相同的。
作者: goal1860    时间: 2010-6-7 21:15
都是一样的毛病,不加selenium.start()




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2