Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium java问题_Java_Selenium - Fatal编程技术网

Selenium java问题

Selenium java问题,java,selenium,Java,Selenium,我无法找出一个问题 方法Test1()未执行。它应该打开yahoo.com package example1; import org.testng.annotations.*; import com.thoughtworks.selenium.*; import java.util.regex.Pattern; public class SimpleTest extends SeleneseTestCase { private DefaultSelenium selenium

我无法找出一个问题

方法Test1()未执行。它应该打开yahoo.com

package example1;

import org.testng.annotations.*;

import com.thoughtworks.selenium.*;

import java.util.regex.Pattern;


public class SimpleTest extends SeleneseTestCase {

    private DefaultSelenium selenium;


    @BeforeSuite(alwaysRun = true)

    public void setUp() throws Exception {

        echo("in setup.");

        selenium = new DefaultSelenium("localhost", 

                4444, "*opera", "http://localhost:8080/");

        echo("selenium instance created:"+selenium.getClass());

        selenium.start();

        echo("selenium instance started. Opening website...");

    }


    @Test(sequential=true)

    public void testTest1() throws Exception {

        echo("testTest1:testing assertion.");

        selenium.open("http://www.yahoo.com");

    }



    // Cleanup the selenium environment

    @AfterSuite(alwaysRun = true)    

    private void stopTest() {

        selenium.stop();

        echo("selenium stopped.");

    }


    private void echo(String msg){
 System.out.println(msg);

        if(new Boolean(System.getProperties().getProperty("DEBUG")))

            System.out.println(msg);

    }



    }  
脚本没有打开yahoo.com 它最后说:

Total tests run: 0, Failures: 0, Skips: 0
谁能告诉我需要什么吗

提前感谢。

你好,jzd
我就这样跟着
用于启动服务器
srinath@srinath-Vostro1510:~/Desktop/testws/lib$java-jar selenium-server.jar-multiwindow 20:17:34信息-Jetty/5.1.x版
20:17:34信息-已启动HttpContext[/selenium服务器/驱动程序,/selenium服务器/驱动程序]
20:17:34信息-已启动HttpContext[/selenium服务器,/selenium服务器]
20:17:34信息-已启动HttpContext[/,/]
20:17:34信息-已在0.0.0.0:4444启动SocketListener
20:17:34信息-启动org.mortbay.jetty。Server@3487a5cc

现在正在运行启动脚本的命令:

srinath@srinath-Vostro1510:~/Desktop/testws$ant run
Buildfile:/home/srinath/Desktop/testws/build.xml

setClassPath:

初始化:

清洁:
[删除]删除目录/home/srinath/Desktop/testws/build

编译:
[echo]制作目录…
[mkdir]创建目录:/home/srinath/Desktop/testws/build
[回声]类路径:/home/srinath/Desktop/testws/lib/junit.jar:/home/srinath/Desktop/lib/selenium java客户端驱动程序tests.jar:/home/srinath/Desktop/testws/lib/lib/lib/selenium java客户端驱动程序jar:/home/srinath/Desktop/testws/lib/selenium-server-0.9.1-20070223.200626-116-standalone.jar:/home/srinath/Desktop/testws/lib/selenium-server.jar:/home/srinath/Desktop/Desktop/Desktop/s/lib/testng-5.5-jdk15.jar:/home/srinath/Desktop/testws/lib/testng.jar
[echo]正在编译…
[javac]/home/srinath/Desktop/testws/build.xml:68:警告:未设置“includeantruntime”,默认为build.sysclasspath=last;对于可重复生成,设置为false
[javac]将1个源文件编译到/home/srinath/Desktop/testws/build

运行:
[testng][Parser]正在运行:
[testng]/home/srinath/Desktop/testws/config/testng.xml
[testng]
[testng]正在设置中。
[testng]创建的selenium实例:class com.thoughtworks.selenium.DefaultSelenium
[testng]已启动selenium实例。正在打开网站…
[testng]
[testng]================================================================
[testng]套件1
[testng]运行的测试总数:0,失败数:0,跳过数:0
[testng]================================================================
[testng]

成功构建

总时间:1分59秒

看起来这与selenium无关,但与如何运行测试有关。已解决。需要在xml文件中进行配置,我们在其中调用要执行的方法。