import junit.framework.SystemTestCase4;
public class GoogleTest extends SystemTestCase4{
private Selenium selenium;
@Test public void setup(){
selenium = new DefaultSelenium("ipaddress", 4444, "*firefox", "http://www.google.com");
selenium.start();
}
@Test public void GoogleSearch(){
selenium.open("http://www.google.com");
//Detect field by name
//Can also detect field by id
if(selenium.isElementPresent("name=q")){
selenium.type("q", "Testing");
}
}
public void tearDown(){
//selenium.stop();
}
}
Regards,
Roy
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear All,
I create a test using Selenium RC & junit & eclipse. It seems like that the test runs, but the browser window stay blank.
Anyone can help?
Test Script:
package org.jsystem.quickstart;
import org.junit.*;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
import junit.framework.SystemTestCase4;
public class GoogleTest extends SystemTestCase4{
private Selenium selenium;
@Test public void setup(){
selenium = new DefaultSelenium("ipaddress", 4444, "*firefox", "http://www.google.com");
selenium.start();
}
@Test public void GoogleSearch(){
selenium.open("http://www.google.com");
//Detect field by name
//Can also detect field by id
if(selenium.isElementPresent("name=q")){
selenium.type("q", "Testing");
}
}
public void tearDown(){
//selenium.stop();
}
}
Regards,
Roy
The browser tries to open: http://localhost:4444/selenium-server/core/Blank.html?start=true for some reason.
I try to run the test on a vmware appliance which is on a server.
Your example gives me
java.lang.NullPointerException
at com.roche.cit1k.SeleniumExample3.GoogleSearch(SeleniumExample3.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
l.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
any suggestions why? Thanks
I've replaced ipaddress with localhost
should
@Test public void setup(){
not be
@Before public void setup(){