量角测试在铬中工作,但在IE11中不工作



我正在尝试在不同的浏览器上进行简单的量角测试,并且我遇到它在IE上失败,但在Chrome上却没有。

我正在http://juliemr.github.io/protractor-demo/上测试AngularJS应用程序,这是一个简单的计算器应用程序。

测试由以下代码组成:

describe('Protractor Demo App', function() {
  it('should add 2 numbers', function() {
    var i,j;
    var w=10000;
    var t=100;
    i=Math.floor((Math.random() * t) + 1);
    j=Math.floor((Math.random() * t) + 1);
    browser.sleep(w);
    browser.get('http://juliemr.github.io/protractor-demo/');
        browser.waitForAngular();
    element(by.model('first')).sendKeys(i);
    element(by.model('second')).sendKeys(j);
    element(by.id('gobutton')).click();
    console.log('Sent: ' + i.toString() + ' + ' + j.toString());
    var x = element.all(by.repeater('result in memory').column('value')).get(0).getText();
    expect(x).toEqual((i+j).toString());

我的配置文件是:

// conf.js
exports.config = {
        capabilities: {
        'browserName': 'internet explorer',
        'platform': 'ANY',
        'version': '11',
        'nativeEvents': false,
        'unexpectedAlertBehaviour': 'accept',
        'ignoreProtectedModeSettings': true,
        'enablePersistentHover': true,
        'disable-popup-blocking': true
    },
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js']
}

当我为Chrome设置最后一个(即,评论功能部分(时,测试作为魅力运行,测试还可以。我看到Chrome窗口弹出,脚本将数字放入,单击按钮,结果出现以及窗口关闭。

当我为IE设置IE(删除功能部分(并启动脚本时,IE窗口弹出了文本" 这是WebDriver Server的初始启动页面。 <</em> "并在那里停留一段时间。之后,我看到脚本放入数字,然后立即关闭,并在日志上进行了失败的测试,并带有消息:

  Message:
    Failed: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator by.repeater("result in memory").column("value")
  Stack:
    NoSuchElementError: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator by.repeater("result in memory").column("value")

似乎没有点击" GO"按钮,但我不明白为什么。谁能帮我了解发生了什么?

谢谢!

奇怪的是,这在Chrome中起作用。最初,我认为这也是一个IE问题。但是,上面的代码存在问题。在您的注释中上面列出的堆栈流链接中,正确使用了列方法。列的用法如下所示。

看上去可疑的代码线:

var x = element.all(by.repeater('result in memory').column('value')).get(0).getText();

这应该是:

var x = element.all(by.repeater('result in memory').column('result .value')).get(0).getText();

此示例与量规则烹饪书几乎相同。我也会检查一下。

相关内容

最新更新