【发布时间】:2019-08-26 02:08:28
【问题描述】:
我试图单击一个弹出按钮,但我的代码显示错误:
“selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互”。
我已经搜索但找不到适合我的弹出按钮解决方案。
Image for clicking show 10 rows and displaying the pop-up box附上的图片是想要的结果,'Show 10 rows'在它后面,很容易看到。
我的 HTML 代码中有这个,需要点击按钮。
<div class="table-responsive">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" id="loadsur" href="#Section" aria-expanded="true">LoadSurvey</a></li>
</ul>
<div class="container-fluid">
<div class="row">
<div class="col-md-12" style="margin-left: -10px;">
<div class="table-responsive">
<div id="myDataTable25_wrapper" class="dataTables_wrapper no-footer"><div class="dt-buttons">
<button class="dt-button buttons-csv buttons-html5" tabindex="0" aria-controls="myDataTable25">
<span>Csv</span></button>
<button class="dt-button buttons-excel buttons-html5" tabindex="0" aria-controls="myDataTable25">
<span>Excel</span></button>
<button class="dt-button buttons-collection buttons-page-length" tabindex="0" aria-controls="myDataTable25" aria-haspopup="true">
<span>Show 10 rows</span></button>
</div>
</div>
</div>
</div>
</div>
在 Python 中我试过这个:
def single_meter(i=0):
browser=webdriver.Chrome('C:\Webdrivers\chromedriver.exe')
for row in range (5,10):
browser.get('http://#link'+consumer_ID+'?reportrange=21%2F07%2F2018-25%2F08%2F2019')
Show10 = find_element_by_xpath("//button[@class='dt-button buttons-collection buttons-page-length']//span[contains(text(),'Show 10 rows')]")
Show10.click()
我希望单击此按钮会出现一个弹出按钮。
【问题讨论】:
-
span不是button,即使它看起来像按钮并且无法单击。你必须找到button并点击它。 -
我也尝试使用按钮,但出现相同的错误消息。请有任何进一步的建议。
-
HTML 中有
iframe吗? -
@MosheSlavin 最后有 iframe 只有这么多
-
@MosheSlavin 所附图像是所需的结果,“显示 10 行”在其后面并且可以轻松看到。
标签: python html python-3.x selenium