Selenium java issue
I was unable to figure out an issue.
The method testTest1() was not executing. It should open 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 stopT开发者_如何学Goest() {
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);
}
}
The script was not opening yahoo.com and it says finally:
Total tests run: 0, Failures: 0, Skips: 0
Can any one tell me what's needed?
Thanks in advance.
Hi jzd
I am following like this
for starting server
srinath@srinath-Vostro1510:~/Desktop/testws/lib$ java -jar selenium-server.jar -multiwindow
20:17:34 INFO - Version Jetty/5.1.x
20:17:34 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
20:17:34 INFO - Started HttpContext[/selenium-server,/selenium-server]
20:17:34 INFO - Started HttpContext[/,/]
20:17:34 INFO - Started SocketListener on 0.0.0.0:4444
20:17:34 INFO - Started org.mortbay.jetty.Server@3487a5cc
now running command to start scripts :
srinath@srinath-Vostro1510:~/Desktop/testws$ ant run
Buildfile: /home/srinath/Desktop/testws/build.xml
setClassPath:
init:
clean:
[delete] Deleting directory /home/srinath/Desktop/testws/build
compile:
[echo] making directory...
[mkdir] Created dir: /home/srinath/Desktop/testws/build
[echo] classpath: /home/srinath/Desktop/testws/lib/junit.jar:/home/srinath/Desktop/testws/lib/selenium-java-client-driver-tests.jar:/home/srinath/Desktop/testws/lib/selenium-java-client-driver.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/testws/lib/testng-5.5-jdk15.jar:/home/srinath/Desktop/testws/lib/testng.jar
[echo] compiling...
[javac] /home/srinath/Desktop/testws/build.xml:68: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to /home/srinath/Desktop/testws/build
run:
[testng] [Parser] Running:
[testng] /home/srinath/Desktop/testws/config/testng.xml
[testng]
[testng] in setup.
[testng] selenium instance created:class com.thoughtworks.selenium.DefaultSelenium
[testng] selenium instance started. Opening website...
[testng]
[testng] ===============================================
[testng] suite1
[testng] Total tests run: 0, Failures: 0, Skips: 0
[testng] ===============================================
[testng]
BUILD SUCCESSFUL
Total time: 1 minute 59 seconds
精彩评论