【问题标题】:Using JavaScript from Selenium RC by Java通过 Java 使用来自 Selenium RC 的 JavaScript
【发布时间】:2011-02-23 10:38:46
【问题描述】:

我在user-extensions.js中有如下函数

file:Selenium.prototype.doTypeRepeated = function(locator, text) {
    // All locator-strategies are automatically handled by "findElement"
    var element = this.page().findElement(locator);

    // Create the text to type
    var valueToType = text + text;

    // Replace the element text with the new text
    this.page().replaceText(element, valueToType);
};

我在 Java 中使用 Selenium RC。我有 Java 类文件“Services_ProcMethodREOI.java”。我在 Java 文件中使用以下行来调用 javascript 函数 typeRepeated():

selenium.getEval("typeRepeated(\"txtAppCode\", \"service5\")");
//txtAppCode is a textfield and service5 is the inputted text on that textfield

当我使用eclipse运行Java文件时,发现如下错误:

com.thoughtworks.selenium.SeleniumException: 错误: 抛出一个 异常:预期对象

请建议我如何解决它。

【问题讨论】:

    标签: java javascript selenium selenium-rc


    【解决方案1】:

    您需要使用 doCommand 方法来触发您创建的新命令。 http://seleniumhq.org/docs/08_user_extensions.html#using-user-extensions-with-selenium-rc 有很好的文档

    【讨论】:

      猜你喜欢
      • 2010-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-16
      • 1970-01-01
      • 2011-11-23
      • 1970-01-01
      • 2011-03-28
      相关资源
      最近更新 更多