Javascript 在量角器中选择单选按钮值

Javascript 在量角器中选择单选按钮值,javascript,protractor,Javascript,Protractor,我有一张有三个单选按钮的表格 <form name="contact"> <label>Type</label> <label> <input type="radio" id="car" value="car" checked>Car </label> <label> <input type="radio" id="boat" value="b

我有一张有三个单选按钮的表格

<form name="contact">
    <label>Type</label>
    <label>
        <input type="radio" id="car" value="car" checked>Car
    </label>
    <label>
        <input type="radio" id="boat" value="boat">Boat
    </label>
    <label>
        <input type="radio" id="home" value="home">Home
    </label>
</form>
运行测试时,出现以下错误:

Message:
  Failed: No element found using locator: By(css selector, *[id="boat"])
Stack:
  NoSuchElementError: No element found using locator: By(css selector, *[id="boat"])

这似乎有效

设置:

  • 量角器4.0.10
  • selenium独立服务器2.53.1
  • 铬驱动2.25
config.js:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js']
}
规范js:

describe('form', () => {
  it('should click boat', () => {
    // test page using the html above. generated a non-angular page
    // on port 8000
    browser.ignoreSynchronization = true;
    browser.get('http://localhost:8000/index.html');

    element(by.id('boat')).click();

    // pause to take a screenshot
    browser.pause();
  });
});
运行到
浏览器的html屏幕截图。暂停
(打开开发工具以显示html):


这似乎有效

设置:

  • 量角器4.0.10
  • selenium独立服务器2.53.1
  • 铬驱动2.25
config.js:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js']
}
规范js:

describe('form', () => {
  it('should click boat', () => {
    // test page using the html above. generated a non-angular page
    // on port 8000
    browser.ignoreSynchronization = true;
    browser.get('http://localhost:8000/index.html');

    element(by.id('boat')).click();

    // pause to take a screenshot
    browser.pause();
  });
});
运行到
浏览器的html屏幕截图。暂停
(打开开发工具以显示html):