Angularjs 使用量角器3.x.x切换到iframe

Angularjs 使用量角器3.x.x切换到iframe,angularjs,selenium,iframe,protractor,e2e-testing,Angularjs,Selenium,Iframe,Protractor,E2e Testing,我正试图在e2e测试中切换到iframe 我的代码是 var el = element(by.id('iframe-container')).element(by.tagName('iframe')); browser.switchTo().frame(el); $('.top-bar-right .btn-primary').click(); browser.switchTo().defaultContent(); 出于某种原因,这不起作用,是否有人知道他们的产品在selenium/D

我正试图在e2e测试中切换到iframe

我的代码是

var el = element(by.id('iframe-container')).element(by.tagName('iframe'));

browser.switchTo().frame(el);

$('.top-bar-right .btn-primary').click();

browser.switchTo().defaultContent();
出于某种原因,这不起作用,是否有人知道他们的产品在selenium/Digrator的最新版本中是否有任何变化

我有selenium版本2.5.x和量角器版本3.1.x

我的测试出现错误:

FATER ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

谢谢大家!

你可以这样写:

browser.ignoreSynchronization=true;
      browser.switchTo().frame('iframe-container').then(function(){
          expect('something').not.toBeNull();
          $('.top-bar-right .btn-primary').click().then(function(){
              browser.switchTo().defaultContent().then(function(){
                  expect('something').not.toBeNull();
              });
          });
      });

你可以这样写:

browser.ignoreSynchronization=true;
      browser.switchTo().frame('iframe-container').then(function(){
          expect('something').not.toBeNull();
          $('.top-bar-right .btn-primary').click().then(function(){
              browser.switchTo().defaultContent().then(function(){
                  expect('something').not.toBeNull();
              });
          });
      });

这对我有用。我的示例是在测试TinyMCE时访问body元素

var test = function(){
    var iframe = element(by.tagName('iframe'));

    // iframe doesn't have angular... 
    browser.ignoreSynchronization = true;

    // must enter the iframe with the WebElement? 
    // or it crashes with out of memory error!! 
    return browser.switchTo().frame(iframe.getWebElement())
          .then(function(){
              // in the iframe.. 
              var editor_body = element(by.tagName('body'));
              editor_body.sendKeys('test');
          })
          .then(function(){
              // restore sync for angular
              browser.ignoreSynchronization = false;
              return browser.switchTo().defaultContent();
          });
};

这对我有用。我的示例是在测试TinyMCE时访问body元素

var test = function(){
    var iframe = element(by.tagName('iframe'));

    // iframe doesn't have angular... 
    browser.ignoreSynchronization = true;

    // must enter the iframe with the WebElement? 
    // or it crashes with out of memory error!! 
    return browser.switchTo().frame(iframe.getWebElement())
          .then(function(){
              // in the iframe.. 
              var editor_body = element(by.tagName('body'));
              editor_body.sendKeys('test');
          })
          .then(function(){
              // restore sync for angular
              browser.ignoreSynchronization = false;
              return browser.switchTo().defaultContent();
          });
};

你能签入chrome和firefox吗?两个浏览器都有相同的错误?是的,两个浏览器都有相同的问题。你能签入chrome和firefox吗?两个浏览器都有相同的错误?是的,两个浏览器都有相同的问题