46312

Selecting a element in a drop-down menu in protractor

Question:

I have a drop-down menu on my page. My goal for protractor testing is to click one of the options of this drop-down menu and have protractor check the results:

<ul class="dropdown"> <li class="nav-header">portfolio</li> <li class="divider"></li> <li class="dropdown-submenu"> ... </li> <li ng-repeat="p in user.portfolios"> <!-- this is the option we will click for our testing --> <a href ng-click="displayPortfolio(p)>Portfolio 1 </a> </li> <li ng-repeat="p in user.portfolios"> <a href ng-click="displayPortfolio(p)>Portfolio 2 </a> </li> <li ng-repeat="p in user.portfolios"> <a href ng-click="displayPortfolio(p)>Portfolio 3 </a> </li> </ul>

my protractor test looks something like:

it('should display relevant portfolio when clicked',function(){ ptor.ignoreSynchronization = true; element.all(by.xpath("//a[@ng-click='displayPortfolio(p)'])).then(function(list){ list[0].click(); expect(... some assertion here); }); ptor.ignoreSynchronization = false; }

Just in case you were wondering, ptor.ignoreSynchronization is enabled because my web-page is constantly polling the backend for some updates.

Protractor throw the following error when I run the test:

ElementNotVisisbleError: element not visible

I don't quiet understand what this error is about. The element is surely visible since when I do view source of the page, I can see it in the DOM structure.

Kindly advice

Answer1:

I have handled same case by setting value directly. locate the element and set the value using "sendKeys".

Try the same for your scenario.

Answer2:

Have you tried using the repeater locator?

it('should display relevant portfolio when clicked',function(){ var elements = element.all(by.repeater('p in user.portfolios')); elements.get(0).click().then(function(){ expect(... some assertion here); }); }

Recommend

  • Django: How to change form field select options with different Querysets, based on other form field
  • progress bars for portfolio items
  • How to construct template for Composite view Dynamically
  • Implementing jQuery isotope
  • Collapsible accordion doesn't work inside a dropdpwn-menu Bootstrap
  • Convert Array to custom object list c#
  • Custom dialog hasn't divider under the title
  • How to change a class of a menu item in Rails
  • Dotted line in android [duplicate]
  • Dictionary of Linq Expression [duplicate]
  • drop-down menu with errors
  • AngularJS Update Service Variable Not Working
  • Foreign key or null value
  • How to change the color of actionbar (actionbarsherlock)
  • How can I add a Submenu to the WordPress Admin Bar
  • Mysql Recursive Stored Procedure…Limit 0 reached…can't change the max_sp_recursion_depth variab
  • How to set the list divider of an MultiAutoCompleteTextView
  • Google reCaptcha - empty error message, not receiving response to challenge (The reCAPTCHA wasn'
  • Uploading to S3 on Heroku with Paperclip (delayed_job question)
  • Integrate two requests into one Javascript
  • Angular page doesn't refresh after data is added or removed
  • Not able to display correct data in table -AngularJS
  • Floated image with variable width and heading with background image
  • Function calls are not supported. Consider replacing the function or lambda with a reference to an e
  • Simulate click Geckofx vb,net
  • How do I access an unhandled exception in an MVC Error view?
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Jquery UI tool tip close icon
  • Google Custom Search with transparent background
  • Meteor helpers not available in Angular template
  • Change multiple background-images with jQuery
  • Align navbar back button on right side
  • HTML download movie download link
  • Sending data from AppleScript to FileMaker records
  • vba code to select only visible cells in specific column except heading
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • Python/Django TangoWithDjango Models and Databases
  • To Get the radio button value in ruby on rails
  • Net Present Value in Excel for Grouped Recurring CF