yimaotao 发表于 2010-5-17 16:59:24

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:42

测试类,你可以拿出来看下否

yimaotao 发表于 2010-5-17 17:02:44

测试类

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/img");//主页的学生世界
                clickAndSelectModalDialog("//div[@id='imglinkone']/a/img");
                selenium.mouseMoveAt("//div[@id='menudiv']/ul/li/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 voidclickForModalDialog(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 voidacceptModalValue(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 StringgenerateModalDialogReturnObject (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:11

你打断点执行,看下是哪行出错了呢?

yimaotao 发表于 2010-5-18 14:29: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=软件学院第三届董事会第一次会议召开");的时候就出现了下面的错误

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
===============================================

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

我觉得是执行selenium.open("/")的时候出错了,可是为什么呢?

yimaotao 发表于 2010-5-18 14:31:01

是我下载的selenium包有问题么?

小米啊 发表于 2010-5-18 22:21:04

你要加一个selenium.start();

SZFrank2007 发表于 2010-5-20 14:58:54

selenium.click("link=软件学院第三届董事会第一次会议召开");
    selenium.click("link=软件学院第三届董事会第一次会议召开");   这连个连接重合了,第一次连接后第二次还是连接相同的。

goal1860 发表于 2010-6-7 21:15:38

都是一样的毛病,不加selenium.start()
页: [1]
查看完整版本: com.thoughtworks.selenium.SeleniumException: Not found