我一直在尝试查找并单击()一个JavaScript渲染图像。 使用css_selector我可以找到该元素,但是,我必须将鼠标悬停在表的第一个元素上才能捕获图像的位置。
<tbody>
<tr __gwt_row="0" __gwt_subrow="0" class="GPBYFDECG">
<td class="GPBYFDEBG GPBYFDEDG GPBYFDEEG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6847" tabindex="0">ACD CALL DETAILS NEW</div></td>
<td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6848">sup001</div></td>
<td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6849">2019-01-22 01:05:57</div></td>
<td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6850"><img onload="this.__gwtLastUnhandledEvent="load";" src="http://172.00.00.00.00:8889/ameyoreports/AmeyoReportsApp/clear.cache.gif" style="width:16px;height:16px;background:url(http://172.00.00.00:8889/ameyoreports/AmeyoReportsApp/0210CFCB6CBE82D7E9FAC82D9F901495.cache.png) no-repeat -308px -25px;" border="0"></div></td>
<td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6851">SUCCESS</div></td><td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6852"></div></td>
<td class="GPBYFDEBG GPBYFDEDG gwt-Clickable-Custom"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6853"><img onload="this.__gwtLastUnhandledEvent="load";" src="http://172.00.00.00.00/ameyoreports/AmeyoReportsApp/clear.cache.gif" style="width:24px;height:24px;background:url(http://172.00.00.00:8889/ameyoreports/AmeyoReportsApp/0210CFCB6CBE82D7E9FAC82D9F901495.cache.png) no-repeat -406px 0px;" border="0"></div></td>
<td class="GPBYFDEBG GPBYFDEDG gwt-Clickable-Custom"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6854"></div></td><td class="GPBYFDEBG GPBYFDEDG"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6855"></div></td><td class="GPBYFDEBG GPBYFDEDG GPBYFDEOG gwt-Clickable-Custom"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6856"></div></td>
</tr>
<tr __gwt_row="1" __gwt_subrow="0" class="GPBYFDEBH">
<td class="GPBYFDEBG GPBYFDECH GPBYFDEEG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-601">ACD CALL DETAILS NEW</div></td>
<td class="GPBYFDEBG GPBYFDECH datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-602">Administrator</div></td>
<td class="GPBYFDEBG GPBYFDECH datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-603">2019-01-22 18:06:58</div></td>
<td class="GPBYFDEBG GPBYFDECH datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-604"><img onload="this.__gwtLastUnhandledEvent="load";" src="http://172.00.00.00:8889/ameyoreports/AmeyoReportsApp/clear.cache.gif" style="width:16px;height:16px;background:url(http://172.00.00.00:8889/ameyoreports/AmeyoReportsApp/0210CFCB6CBE82D7E9FAC82D9F901495.cache.png) no-repeat -308px -25px;" border="0"></div></td>
<td class="GPBYFDEBG GPBYFDECH datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-605">SUCCESS</div></td><td class="GPBYFDEBG GPBYFDECH datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-606"></div></td>
<td class="GPBYFDEBG GPBYFDECH gwt-Clickable-Custom"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-607"><img onload="this.__gwtLastUnhandledEvent="load";" src="http://172.00.00.00:8889/ameyoreports/AmeyoReportsApp/clear.cache.gif" style="width:24px;height:24px;background:url(http://172.00.00.00:8889/ameyoreports/AmeyoReportsApp/0210CFCB6CBE82D7E9FAC82D9F901495.cache.png) no-repeat -406px 0px;" border="0"></div></td>
<td class="GPBYFDEBG GPBYFDECH gwt-Clickable-Custom"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-608"></div></td><td class="GPBYFDEBG GPBYFDECH"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-609"></div></td><td class="GPBYFDEBG GPBYFDECH GPBYFDEOG gwt-Clickable-Custom"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-610"></div</td>
</tr>
<tr __gwt_row="2" __gwt_subrow="0" class="GPBYFDECG">
<td class="GPBYFDEBG GPBYFDEDG GPBYFDEEG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6847" tabindex="0">ACD CALL DETAILS NEW</div></td>
<td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6848">sup001</div></td>
<td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6849">2019-01-22 01:05:57</div></td>
<td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6850"><img onload="this.__gwtLastUnhandledEvent="load";" src="http://172.16.10.23:8889/ameyoreports/AmeyoReportsApp/clear.cache.gif" style="width:16px;height:16px;background:url(http://172.00.00.00:8889/ameyoreports/AmeyoReportsApp/0210CFCB6CBE82D7E9FAC82D9F901495.cache.png) no-repeat -308px -25px;" border="0"></div></td>
<td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6851">SUCCESS</div></td><td class="GPBYFDEBG GPBYFDEDG datagridCellStyle"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6852"></div></td>
<td class="GPBYFDEBG GPBYFDEDG gwt-Clickable-Custom"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6853"><img onload="this.__gwtLastUnhandledEvent="load";" src="http://172.16.10.23:8889/ameyoreports/AmeyoReportsApp/clear.cache.gif" style="width:24px;height:24px;background:url(http://172.00.00.00:8889/ameyoreports/AmeyoReportsApp/0210CFCB6CBE82D7E9FAC82D9F901495.cache.png) no-repeat -406px 0px;" border="0"></div></td>
<td class="GPBYFDEBG GPBYFDEDG gwt-Clickable-Custom"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6854"></div></td><td class="GPBYFDEBG GPBYFDEDG"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6855"></div></td><td class="GPBYFDEBG GPBYFDEDG GPBYFDEOG gwt-Clickable-Custom"><div style="outline-style:none;" __gwt_cell="cell-gwt-uid-6856"></div></td>
</tr>
</tbody>
现在,我需要单击第一行的第7个子项,该子项会动态更改。首先,它将是一个不同的图像,经过处理后,它将是一个PNG按钮,可以单击它并可以下载报告。
通过使用下面的代码,我能够找到所需的元素。但是,我必须手动将鼠标悬停在第一行上。此外,如果我不小心将鼠标悬停在第二行或第三行上,则会下载第二行和第三行的内容,而不是第一行。
WebDriverWait(driver, 60).until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".GPBYFDEKG:nth-child(7) img"))).click()
有什么方法可以单击第一行的第7个孩子,而无需手动将其悬停在上面吗?
答案 0 :(得分:0)
我不确定它是否可以在Python中运行,但是您可以尝试以下XPath:
TextWatcher
或
//tr[@__gwt_row='0']/td[last()]