0

I'm trying to get the value of a selected drop-down.

I found an question on SO on how to select the value I want, I found several that claim to say how to get the text of the selected value for Expects testing, but i can't get their answers to work. It's very probably because of my extensive 3 hours of Protractor experience.

Can you assist?

element(by.css('[value="' + 1 + '"]')).click();

expect(element(by.name('selectedCallscript'))
  .$('option:checked')
  .getText()
)
.ToEqual('Action Verification');

I'm using the latest Protractor, because I downloaded it a few hours ago.

I get an undefined on the .ToEqual, I've also tried .equals and .contains.

Eric Brown - Cal
  • 14,135
  • 12
  • 58
  • 97

1 Answers1

0

It is called toEqual(). Replace:

expect(element(by.name('selectedCallscript')).$('option:checked').getText()).ToEqual('Action Verification');

with:

expect(element(by.name('selectedCallscript')).$('option:checked').getText()).toEqual('Action Verification');
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • When i use that I get "Cannot read Property 'count' of undefined, and the error is deep down in the protractor code. I'm not using count anywhere and the line above is the last line of my app. – Eric Brown - Cal Jun 02 '15 at 15:30
  • @EricBrown-Cal okay, how about replacing `element(by.name('selectedCallscript')).$('option:checked').getText()` with `element(by.name('selectedCallscript')).element(by.css('option:checked')).getText()`? – alecxe Jun 02 '15 at 16:13