google / pageloader

A framework for creating page objects for in-browser or WebDriver tests.
https://pub.dartlang.org/packages/pageloader
Apache License 2.0
40 stars 46 forks source link

Handle material-dropdown-select behavior #172

Closed e-belair closed 5 years ago

e-belair commented 5 years ago

Hi, I need to simulate a selection of an item on a material dropdown select How I can do this?

I tried this but it does not seem to work:

  /// material-dropdown-select
  @First(ById('zonage'))
  PageLoaderElement get zonage;

  @ByTagName('material-select-dropdown-item')
  List<PageLoaderElement> get items;

/// In the test
  test('enable zone on zonage selection', () async {
    await po.zonage.click();
    await po.items[2].click(); // index out of range error
  });
mk13 commented 5 years ago

Hi, sorry I had my notifications turned off.

If your elements are coming from an overlay, you need to extract 'material-select-dropdown-item' from the overlay element.

@ByCss(<overlay selector>)
List<PageLoaderElement> get _overlayElement;

List<PageLoaderElement> get items => _overlayElement.createList(ByTagName('material-select-dropdown-item'), [], []);