用新方法扩展 Selenium RC
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这意味着您在用户扩展文件中的命令未找到该元素。尝试在 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
这对我有用。以下是修改后的 user-extensions.js 文件代码:
其余部分保持不变。希望这有帮助!
It works for me. Here is the modified user-extensions.js file code:
Rest all remains the same. Hope this helps!!!