2010-11-18 57 views
0

我使用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 

在这个问题上的任何帮助?

回答

0

这意味着您在用户扩展文件中的命令没有定位元素。尝试在IDE中运行,并检查它是否正常工作

0

它适用于我。这里是修改后的用户扩展名.js文件代码:

Selenium.prototype.doMyMethod = function(locator) { 
    var element = this.page().findElement(locator); 
    element.click(); 
}; 

其余全部保持不变。希望这可以帮助!!!