angular-ui / ui-select

AngularJS-native version of Select2 and Selectize
MIT License
3.26k stars 1.82k forks source link

Protractor Testing Guidance #270

Open JustinDSN opened 9 years ago

JustinDSN commented 9 years ago

Any guidance on how to best test this directive with a Protractor end-to-end test? I tried to add an id attribute to the ui-select directive but it was replaced by the directive's replaced template.

dimirc commented 9 years ago

Currently the id attribute isn't passed. Honestly I haven't use protractor so I'm not sure if the id is all needed

keithharvey commented 9 years ago

Using the outside container class ('type', but this could easily be an id)

it "selects a type", ->
    element(by.css(".type button")).click()
    element(by.linkText("Product")).click()
awerlang commented 9 years ago
var selectButton = element(by.name('fieldName'));
var selectInput = selectButton.element(by.css('.ui-select-search'));

// click to open select
selectButton.click();
// type some text
selectInput.sendKeys('Person name');
// select first element
element.all(by.css('.ui-select-choices-row-inner span')).first().click();

Tip: wrap into a page object to make things easier

rfodge commented 8 years ago

Did anyone have issues with protractor waiting for these elements to load? We have to add browser.sleep() in because it doesn't wait for these elements, which angular components protractor normally does by default.

BjoernKW commented 8 years ago

I'm having problems with Select2 and Protractor as well. Select2's behaviour with Protractor seems rather unpredictable when filtering and selecting elements. Sometimes elements will be selected, sometimes not. The only way to enforce consistent behaviour right now appears to be using browser.sleep(), which is a rather ugly hack and unnecessarily slows down tests.