【问题标题】:Passing parameters into browser.executeScript将参数传递到 browser.executeScript
【发布时间】:2020-07-28 14:54:42
【问题描述】:

如何将参数传入browser.executeScript

  static sortableDragAndDropByClassName(dragElementClassName: string, dropElementClassName: string) {
    return browser.executeScript(function () {
      console.log(dragElementClassName);
      console.log(dropElementClassName);
    });
  }

给我以下错误信息:

- Failed: javascript error: dragElementClassName is not defined

我的测试:

 Helpers.sortableDragAndDropByClassName('page-row-option-item-1', 'page-row-option-item-0').then(() => {

 ...

 });

【问题讨论】:

标签: javascript angular types protractor


【解决方案1】:

您应该能够将这些变量作为参数传递并像这样访问它们。

return browser.executeScript(function () {
  console.log(arguments[0]);
  console.log(arguments[1]);
}, dragElementClassName, dropElementClassName);

【讨论】:

    猜你喜欢
    • 2013-01-31
    • 2015-11-03
    • 2016-09-02
    • 2014-07-20
    • 1970-01-01
    • 2014-01-05
    • 2011-06-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多