Element is not clickable at point - Protractor

Andurit picture Andurit · Jun 16, 2015 · Viewed 12.9k times · Source

I'm getting an error that element I am trying to click on is not click able which I belieave is not true.

My error looks:

 1) Open VehiclePage and populate data Populate vehicle data
  Message:
    UnknownError: unknown error: Element is not clickable at point (1315, 371). Other element would receive the click: <div class="form-con
rol combo-options ng-scope ng-animate ng-leave ng-leave-active" ng-if="comboBox.visible" on-click-outside="comboBox.hide">...</div>
 (Session info: chrome=39.0.2171.71)
 (Driver info: chromedriver=2.13.307647 (5a7d0541ebc58e69994a6fb2ed930f45261f3c29),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server
did not provide any stacktrace information)
ommand duration or timeout: 30 milliseconds

Part of my code:

it('Populate vehicle data', function() {
        browser.waitForAngular();
        element(by.css('div#datepicking i.glyphicon-calendar')).click();
        element(by.css('div#datepicking button[ng-click="select(\'today\')"]')).click();
        element(by.model('case.vehicle.adminData.paintColour')).sendKeys(browser.params.paintColour);       
        element(by.xpath('(//*[@id="form-mileage"])')).sendKeys(browser.params.mileage);                        
        element(by.id('form-mileage-unit')).click().then(function() {
            element(by.cssContainingText('option', browser.params.lengthUnit)).click();         
        });;
        element(by.xpath('(//*[@id="form-residual"])')).sendKeys(browser.params.technicalValue);    
        element(by.id('form-vehicle-condition')).click().then(function() {
            element(by.cssContainingText('option', browser.params.vehicleCondition)).click();
        });;    
        element(by.xpath('(//*[@id="form-engine-type"])')).click().then(function() {
            element(by.cssContainingText('option', browser.params.motorType)).click();
        });;

HTML of that part looks like:

<div class="col-md-6">
                <div>
                    <div class="form-group">
                        <label for="form-residual" ng-class="{red: !form.residual.$valid}" translate="case.vehicle.adminData.residualValuePercentage" class="ng-scope">Technická hodnota</label>
                           <span popover="Technická hodnota musí být v rozsahu 0-100%" popover-trigger="mouseenter" class="glyphicon glyphicon-question-sign red ng-hide" ng-show="form.residual.$invalid"></span>
                        <div class="input-group">
                            <input type="number" id="form-residual" ng-model="case.vehicle.adminData.residualValuePercentage" name="residual" class="form-control ng-pristine ng-untouched ng-valid ng-valid-min ng-valid-max" max="100" min="0">
                            <span class="input-group-addon">%</span>
                        </div>
                    </div>
                </div>
                <div>
                    <div class="form-group">
                        <label for="form-vehicle-condition" translate="case.vehicle.adminData.vehicleCondition" class="ng-scope">Stav vozu</label>
                        <select type="text" id="form-vehicle-condition" ng-model="case.vehicle.adminData.vehicleCondition" name="vehicleCondition" class="form-control ng-pristine ng-valid ng-touched" ng-options="opt.value as opt.label | translate for opt in options.vehicleCondition"><option value="" class=""></option><option value="0" label="Lepší">Lepší</option><option value="1" label="Odpovídající">Odpovídající</option><option value="2" label="Horší">Horší</option><option value="3" label="Není znám">Není znám</option></select>
                    </div>
                </div>
            </div>

Error comes out always when trying to click element(by.id('form-vehicle-condition'). Is there a chance someone can help me to find a way out of it?

Answer

Delian Mitankin picture Delian Mitankin · Jun 16, 2015

The combo-box from the error message is still open when you are trying to click on the vehicle-condition element - most probably due to its closing/fade-out animation. You can try to disable animations for your tests globally, locally or wait for the overlaying element to disappear:

var EC = protractor.ExpectedConditions;
var element = element(by.id('form-vehicle-condition'));
var isClickable = EC.elementToBeClickable(element);
browser.wait(isClickable, 5000);
element.click();