Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript E/launcher-过时元素引用:元素未附加到页面文档_Javascript_Selenium_Protractor_Bdd_Cucumberjs - Fatal编程技术网

Javascript E/launcher-过时元素引用:元素未附加到页面文档

Javascript E/launcher-过时元素引用:元素未附加到页面文档,javascript,selenium,protractor,bdd,cucumberjs,Javascript,Selenium,Protractor,Bdd,Cucumberjs,我定义了以下两个场景: @high @basic Scenario Outline: dropdown boxes exist When I am on the Enernoc application Then application is running And <dropdown box> is present Examples: |dropdown box| |templateSelection| |te

我定义了以下两个场景:

@high @basic
  Scenario Outline: dropdown boxes exist
    When I am on the Enernoc application
    Then application is running
    And <dropdown box> is present

    Examples:
      |dropdown box|
      |templateSelection|
      |templateDeliveryPathSelection|
      |templateLocaleSelection|


  @high
  Scenario Outline: dropdown boxes appear and work as expected.
    Given I am on the Enernoc application
    Then application is running
    When click <box>
    Then <option> present in <box>

    Examples:
      |box| option|
      |templateSelection| Apparent Energy |
      |templateDeliveryPathSelection| EMAIL |
在另一个文件中,我有以下代码:

clickDropdown: function(dropdown,callback) {
        element(by.id(dropdown)).click().then(function () {
           callback();
        });
    },

    checkDropdown: function (value,dropdown) {
       expect(element(by.id(dropdown)).$('option:checked').getText()).eventually.equal(value);
    },
我在输出中收到一个错误,通知如下:

stale element reference: element is not attached to the page document
  (Session info: chrome=68.0.3440.106)
  (Driver info: chromedriver=2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db),platform=Mac OS X 10.13.6 x86_64)
[12:15:17] E/launcher - StaleElementReferenceError: stale element reference: element is not attached to the page document
  (Session info: chrome=68.0.3440.106)
  (Driver info: chromedriver=2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db),platform=Mac OS X 10.13.6 x86_64)
我怎样才能修好它?似乎出于某种原因,它在尝试访问元素时没有找到该元素。有什么想法吗


根据详细输出,错误似乎出现在checkDropdown部分。

知道哪个函数抛出了陈旧元素引用错误吗?单击或检查?能否共享
元素
功能的代码?我猜这是一个围绕着driver.findElement编写的包装器,但我觉得它的意义不止于此,而且可能还有根本原因……在两种情况中的一种情况下会引发过时的元素引用异常,第一个比第二个更常见:元素已被完全删除,或者元素不再附加到DOM。请一步一步地查找发生此错误的元素,然后一个策略是重新定义它,然后与它交互。
stale element reference: element is not attached to the page document
  (Session info: chrome=68.0.3440.106)
  (Driver info: chromedriver=2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db),platform=Mac OS X 10.13.6 x86_64)
[12:15:17] E/launcher - StaleElementReferenceError: stale element reference: element is not attached to the page document
  (Session info: chrome=68.0.3440.106)
  (Driver info: chromedriver=2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db),platform=Mac OS X 10.13.6 x86_64)