用新方法扩展 Selenium RC

发布于 2024-10-03 07:38:09 字数 1754 浏览 2 评论 0原文

我正在使用 user-extension.js 扩展 selenium RC。 它能够调用新方法函数,但抛出以下错误消息。

*错误:命令执行失败。请在 http://clearspace.openqa.org 中搜索论坛,了解日志窗口中的错误详细信息。 错误消息是:对象不支持此属性或 方法*

由于该程序是在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 和 Selenium JAR 位于同一文件夹中,并使用以下命令执行 Selenium JAR。

java -jar selenium-server.jar -userExtensions user-extensions.js  

对这个问题有帮助吗?

I am extending the selenium RC by using user-extension.js.
It is able to call the new method function, but throwing following error message.

*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
*

As this program is executed on Google.com, any one can copy the sample code and execute on their respective PCs.

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 and Selenium JAR are in the same folder and executing the Selenium JAR using following command.

java -jar selenium-server.jar -userExtensions user-extensions.js  

Any help on this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

给不了的爱 2024-10-10 07:38:10

这意味着您在用户扩展文件中的命令未找到该元素。尝试在 IDE 中运行它并检查它是否正常工作

It means that your command in user-extension file is not locating the element. Try running that in the IDE and check if it works fine

爱冒险 2024-10-10 07:38:10

这对我有用。以下是修改后的 user-extensions.js 文件代码:

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

其余部分保持不变。希望这有帮助!

It works for me. Here is the modified user-extensions.js file code:

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

Rest all remains the same. Hope this helps!!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文