【问题标题】:Protractor + angular error - Element is not clickable at point量角器 + 角度误差 - 元素在点处不可点击
【发布时间】:2015-03-03 05:15:12
【问题描述】:

当尝试使用量角器和角度测试模态窗口上的可见按钮时,我收到以下错误:

UnknownError:未知错误:元素在点 (400, 234) 处不可点击。其他元素会收到点击:<div class="modal-footer">...</div>'。

我尝试在每个语句之前将窗口大小调整为更大的大小,并在单击之前尝试滚动到页面顶部。有什么建议吗?

代码:

it('should create a new portfolio when modal form is completed', function () {
    portfolio_create_btn.first().click().then();
    element(by.model('portfolios.portName')).sendKeys('Test');
    element(by.css('#portfolio-modal-create-button')).click();

    Tabs.filter(function (elem, index) {
        return elem.getTagName('tab-heading').getText();
    }).then(function (filteredElements) {
        expect(filteredElements.length).toEqual(expect_tabs_len_start + 1);
    });
});

大部分 HTML:

        <div class="container-fluid">
            <h1 class='port-title port-manager-header title custom-inline'>Portfolios</h1>

            <div ng-controller="ModalCtrl" class='create-new-frame'>
                <!--todo move to a partial or into $templateCache -->
                <script type="text/ng-template" id="myModalContent.html">
                    <div class="modal-header">
                        <h3 class="modal-title">Create New Portfolio</h3>
                    </div>
                    <form name='eventForm' method="POST">
                        <div class="modal-body">
                            <input id='create-new-portfolio-input' class='form-control' ng-model='portfolios.portName'
                                   placeholder='Portfolio name' ng-required='true' maxlength="35" focus-me="true">
                            <span class="help-inline" ng-show="notUnique">Portfolio name already used</span>
                            <!-- 
                            Private/Group selection to be used in future versions
                            <div ng-init="radioModel = 'Right'; portfolios.groupSelection = false" class="btn-group">
                                <label class="btn btn-primary" ng-model="radioModel" ng-click='portfolios.groupSelection = true' btn-radio="'Left'">Group</label>
                                <label class="btn btn-primary" ng-model="radioModel" ng-click='portfolios.groupSelection = false' btn-radio="'Right'">Private</label>
                            </div> 
                            -->
                        </div>
                        <div class="modal-footer">
                            <button class="btn btn-primary" ng-click="ok(portfolios.portName)"
                                    ng-disabled="eventForm.$invalid || notUnique" id='portfolio-modal-create-button'>
                                Create
                            </button>
                            <button class="btn btn-warning" ng-click="cancel()" id='portfolio-modal-cancel-button'>Cancel</button>
                        </div>
                    </form>
                </script>
                <button class="btn btn-sm btn-primary create-new-frame-btn" ng-click="open('sm')">Create New</button>
            </div>
            <div class="title port-title custom-inline pull-right">
            <!-- <span class="text-muted">
                Organization // user
            </span> -->
            </div>
        </div>

【问题讨论】:

  • 您能否提供包含id="portfolio-modal-create-button" 元素的表单的HTML 代码?谢谢。
  • 刚刚添加了 HTML。可能是因为 HTML 在
  • 你能试试下面的element(by.css('div.modal-footer button#portfolio-modal-create-button')).click();吗?谢谢。
  • 您的建议导致了同样的错误。我认为错误是指这行代码:return elem.getTagName('tab-heading').getText();,因为模式保持打开状态,所以它被隐藏了。在输入投资组合名称之前,模式创建按钮处于禁用状态,但以下行应该输入名称,尽管我没有在屏幕上看到它发生:element(by.model('portfolios.portName')).sendKeys('Test');。我尝试#portfolio-modal-cancel-button 只是为了测试这个理论,但收到了同样的错误。

标签: javascript angularjs testing protractor end-to-end


【解决方案1】:

事实证明,导致问题的之前的测试是打开模态并将其保持打开状态,然后当这个测试试图打开一个新的模态时,由于模态已经打开,找不到这样做的按钮.在我仔细观察之前,我没有意识到测试的第一行导致了错误。问题解决了。

【讨论】:

    猜你喜欢
    • 2016-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多