2010-11-18 8 views
0

user-extension.jsを使用してセレンRCを拡張しています。 新しいメソッド関数を呼び出すことはできますが、次のエラーメッセージがスローされます。新しいメソッドでSelenium 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

変更されたuser-extensions.jsファイルのコードは次のとおりです。

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

残りはすべて同じです。お役に立てれば!!!

関連する問題