Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.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 禁用的锚返回使用WebElement.isEnabled()启用的锚_Javascript_Angularjs_Selenium_Selenium Webdriver_Protractor - Fatal编程技术网

Javascript 禁用的锚返回使用WebElement.isEnabled()启用的锚

Javascript 禁用的锚返回使用WebElement.isEnabled()启用的锚,javascript,angularjs,selenium,selenium-webdriver,protractor,Javascript,Angularjs,Selenium,Selenium Webdriver,Protractor,由于某些原因,elmFinder.isEnabled()即使在禁用的html锚标记上也会解析为true 我已经安装了一个 当IMHO不应进行下列量角器测试时,以下量角器测试失败 describe('isEnabled() should resolve to true on any html element', function() { var checkElm = element(by.model('checked')); var btnElm = element(by.model('b

由于某些原因,
elmFinder.isEnabled()
即使在禁用的html锚标记上也会解析为
true

我已经安装了一个

当IMHO不应进行下列量角器测试时,以下量角器测试失败

describe('isEnabled() should resolve to true on any html element', function() {
  var checkElm = element(by.model('checked'));
  var btnElm = element(by.model('button'));
  var linkElm = element(by.model('link'));

  it('open test page', function() {
    browser.get('http://run.plnkr.co/plunks/oExtzK/');
  });

  it('should be enabled by default: button & link', function() {
    expect(btnElm.isEnabled()).toBeTruthy();
    expect(linkElm.isEnabled()).toBeTruthy();
  });

  it('clicks the checkbox to switch enabled/disabled status', function() {
    checkElm.click();
  });

  it('button should now be disabled', function() {
    expect(btnElm.isEnabled()).toBeFalsy();
  });

  // This fails
  it('link should now be disabled', function() {
    expect(linkElm.isEnabled()).toBeFalsy();
  });
});
输出:

Describe: isEnabled() should resolve to true on any html element
 001 - open test page ✔
 002 - should be enabled by default: button & link ✔
 003 - clicks the checkbox to switch enabled/disabled status ✔
 004 - button should now be disabled ✔
 005 - link should now be disabled  FAILED!
   Message:    Expected true to be falsy.
   Stacktrace: Error: Failed expectation

对于除禁用的输入元素之外的所有元素,通常都将返回true

因此我认为,解决方法是使用+否定
elm.getAttribute('disabled')
而不是
elm.isEnabled()

it('link should now be disabled', function() {
  expect(linkElm.getAttribute('disabled')).toBeTruthy();
});