元素在点处不可点击 - 量角器 [英] Element is not clickable at point - Protractor

查看:130
本文介绍了元素在点处不可点击 - 量角器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个错误,我试图点击的元素不是点击,我相信不是真的。

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

我的错误看起来:

 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

我的部分代码:

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如下所示:

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>

尝试点击元素时出现错误(by.id('form-vehicle-condition') )。
是否有人可以帮助我找到解决办法?

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?

推荐答案

组合 - 当您尝试单击 vehicle-condition 元素时,错误消息中的框仍然打开 - 很可能是由于其关闭/淡出动画。
您可以尝试在全球范围内禁用测试动画本地等待,覆盖元素消失:

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();

这篇关于元素在点处不可点击 - 量角器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆