Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I want to test a smart GWT app using Selenium. For this I need to add up 1. user-extensions.js 2. user-extensions-ide.js in the IDE. This gives an additional scLocators for locating GWT elements on the page

Now if I want to test the above page using Java, then where will I add these js files in the code

share|improve this question
    
did you already find a way to achieve this? –  Laurens Rietveld Sep 27 '13 at 14:21

1 Answer 1

up vote 0 down vote accepted

The way I approached this was using the SeleniumServer method, which allowed me to specify my extension file from the java code.

A working SmartGWT example is:

public class Example  {

SeleniumServer server = null;
Selenium selenium = null;
HttpCommandProcessor proc = null;

@Before
public void setUp() throws Exception {
    RemoteControlConfiguration config = new RemoteControlConfiguration();
    config.setUserExtensions(new File("bin/selenium/user-extensions.js"));
    server = new SeleniumServer(config);

    server.boot();

    proc = new HttpCommandProcessor("localhost",
            4444,
            "*firefox",
            "http://test");

    selenium = new DefaultSelenium(
             proc);
    selenium.start();
    selenium.open("http://test");

}
@Test      
public String justATest() {
    execCommand("waitForElementClickable", "scLocator=//Window[ID=\"errorWindow\"]/item[0][Class=\"Label\"]/");
    String elementTest = selenium.getText("scLocator=//Window[ID=\"errorWindow\"]/item[0][Class=\"Label\"]/");
    assertEquals(elementTest, "lorem");
}
protected String execCommand(String command, String locator) {
    String[] locatorArg = {locator};
    return proc.doCommand(command, locatorArg);
}

@After
public void stopSelenium() {
    System.out.println("in after hook");
    if (selenium != null) {
        selenium.deleteAllVisibleCookies();
        selenium.stop();
    }

    if (server != null) {
        server.stop();
    }
    System.out.println("after after hook");
}
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.