我使用user-extension.js扩展了硒RC。 它能够调用新的方法函数,但会抛出以下错误消息。用新方法扩展硒RC
*ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window. The error message is: Object doesn't support this property or method*
由于此程序在Google.com上执行,任何人都可以复制示例代码并在各自的PC上执行。
package package1;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.*;
import com.thoughtworks.selenium.*;
public class Sample2
{
private static final String Timeout = "30000";
private static final String BASE_URL = "http://google.com/";
private static final String BASE_URL_1 = "/";
private Selenium selenium;
private HttpCommandProcessor proc;
@BeforeClass
protected void setUp()throws Exception
{
proc = new HttpCommandProcessor("localhost", 4444, "*iexplore", BASE_URL);
selenium = new DefaultSelenium(proc);
selenium.start();
selenium.windowFocus();
selenium.windowMaximize();
selenium.windowFocus();
}
@AfterClass(alwaysRun=true)
protected void tearDown() throws Exception
{
selenium.stop();
}
@Test(groups="search")
public void test_GoogleSearch() throws Exception
{
selenium.open(BASE_URL_1);
selenium.type("name=q", "Bharath Marrivada");
//selenium.click("btnG");
proc.doCommand("myMethod",new String[] {"btnG"}); //user extension
Thread.sleep(5000);
}
}
user-extension.js
Selenium.prototype.doMyMethod = function(inputParams)
{
this.browserbot.click("btnG");
return null;
};
.js
和硒JAR是在同一文件夹,并执行使用以下命令硒JAR。
java -jar selenium-server.jar -userExtensions user-extensions.js
在这个问题上的任何帮助?