我正在尝试在选择选项中测试项目文本,但我的测试失败了,这是我的规范,这是我的错误:

它(“应测试sorting_options文本”,function(){

  expect(element.all((by.id('sorting_options')).Last().text).toBe('Score');
});


这是我收到的错误:

C:\ wamp \ www \ First-angular-App> protractor conf.js

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http: //192.168.100.9:31794/wd/hub
[launcher] Error: C: \wamp\ www\ First - angular - App\ protractorSpec\        spec.js: 38


如何解决这个问题?

最佳答案

尝试这个:

var list = element.all(by.css('.dropdown option'));
expect(list.get(0).getText()).toBe('Please Select for sorting');
expect(list.get(1).getText()).toBe('Title');
expect(list.get(2).getText()).toBe('Score');

10-06 11:51