如何计算量角器中的选择选项?

Has*_*san 5 javascript select selenium-webdriver protractor

我想计算 select 属性中的选项,但我的测试失败了,这是我的规范:

it('should count the number of option', function()) {

 expect(element(by.id('sorting_options')).all(by.tagName('option').count())).toBe(3);

}
Run Code Online (Sandbox Code Playgroud)

它给了我错误:

C:\wamp\www\First-angular-App>protractor conf.js 启动 selenium 独立服务器... [启动器] 运行 1 个 WebDriver Selenium 独立服务器实例,启动于 http://192.168.100.9:12708/wd/hub [启动器]错误:C:\wamp\www\First-angular-App\protractorSpec\spec.js:37 it('应该计算选项的数量',function()){ ^

fin*_*pin 4

您的代码格式错误,正确的语法如下:

it('should count the number of option', function () {
    expect(element(by.id('sorting_options')).all(by.tagName('option')).count()).toBe(3);
});
Run Code Online (Sandbox Code Playgroud)