硒元素不可点击

时间:2019-07-19 17:04:41

标签: javascript html selenium

单击网站上的链接后,URL不会更改,但是将在屏幕上加载弹出式窗口,其中包含我只能在运行driver.switchTo().defaultContent()后才能访问的元素 我只能使用await driver.executeScript("document.getElementById('viewDevice').click()");使用javascript执行程序来访问元素 我在该行之后收到以下错误(滚动到右侧以查看整个错误)

整个页面的HTML很大,因此我附加了一个屏幕截图,显示了markdown的Main Tag的压缩HTML。您会看到,将鼠标悬停在body标签上时,会有一个元素阻塞整个屏幕。所以问题似乎是,如何单击整个屏幕顶部透明元素下方的元素?谢谢你的帮助!这已经困扰了我好几天了!

     (node:19397) UnhandledPromiseRejectionWarning: WebDriverError: unknown error:

                    Element <a ng-if="isDTTModalViewOn" tabindex="0" ng-click="dttDialog()"
            ddh-modal="" window-class="modal-fullscreen light-theme" size-class="" 
        modal-ok="ok()" modal-cancel="cancel()" href="javascript:void(0);" 
    class="ng-scope ng-isolate-scope">...</a> is not clickable at point (413, 988). 
Other element would receive the click: <div class="fsrModalBackdrop fsrAbandonButton" id="fsrFullScreenContainer" data-isbackdrop="true">...</div>
  

下面是我要访问的被阻止元素的html

<div class="top-5px float-left" style="width: 405px;">
        <div class="MyBillWDBg298" id="viewDevice">
            <div class="">
                <a role="button" aria-haspopup="true" aria-expanded="false" aria-controls="viewDeviceBox" class="btnimg block" tabindex="0" style="text-decoration: none !important;" name="View Usage for">
                    <div style="min-height:36px; " class="MyBillWDBg298 ">

                                <p class="PadTop10 PadBot5 PadLeft10 botMar0 deviceName ellipsis PadRight10">



name | phone#
                                </p>


                    </div>
                </a>
            </div>
            <div id="viewDeviceBox" role="group" aria-label="Device info" style="position: absolute; display: none;" class="z1000WithoutErrorMsg ">
                <div style="width: 298px;" class="box no-top-round ">
                    <dl class="MarLeft10 MarTop15 botMar15">

                            <dd class="botMar10 MarRight10 ">
                                <span class="block" style="width: 230px;"><a class="wt_Body" linkname="Device DropDown_#" name="Tyler Fox" href="#" onclick="doUsageDeviceContent( 'phone#' ); DTMReportingHelper.triggerLinkClickReporting(this);">


name | #
                                </a></span>
                            </dd>


                            <dd class="botMar10 MarRight10 ">
                                <span class="block" style="width: 230px;"><a class="wt_Body" linkname="Device DropDown_#" name="name" href="#" onclick="doUsageDeviceContent( '#' ); DTMReportingHelper.triggerLinkClickReporting(this);">


name | phone#
                                </a></span>
                            </dd>


                            <dd class="botMar10 MarRight10  orangeCheck ">
                                <span class="block" style="width: 230px;"><a class="wt_Body" linkname="Device DropDown_phone#" name="users name" href="#" onclick="doUsageDeviceContent( 'phone#' ); DTMReportingHelper.triggerLinkClickReporting(this);">


name | phone#
                                </a></span>
                            </dd>


                    </dl>
                </div>
            </div>
        </div>
        <div class="clear"></div>
    </div>

Element I am trying to access

Element blocking elements underneath

1 个答案:

答案 0 :(得分:0)

我要单击的元素包含在iframe中。通过弄清楚iframe的名称,在本例中为“ frame_a”,我可以使用切换框架功能来访问它。

driver.switchTo().frame("iframe_a");

切换框架后,我可以使用javascript执行程序单击该元素。