我将其中一个链接伪装成我需要点击的表单上的按钮,但我无法弄清楚如何操作,这就是元素的样子:
<td id="pt1:r1:0:cf22" class="CreateQuoteBigButtonCell">
<a id="pt1:r1:0:cl7u" class="af_commandLink" onclick="return false;" href="#">
<table id="pt1:r1:0:tl6u" summary="" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr id="pt1:r1:0:rl14u">
<td id="pt1:r1:0:cf23u" class="CreateQuoteBigButtonCell1"><img id="pt1:r1:0:i9u" class="af_image" src="/portal/images/quote/addaproduct.png"></td>
<td id="pt1:r1:0:cf24u">
<table id="pt1:r1:0:rl15u" summary="" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td id="pt1:r1:0:cf25u" class="CreateQuoteBigButtonCell2">Add a Product or Service</td>
</tr>
</tbody>
</table>
<table id="pt1:r1:0:rl16u" summary="" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td id="pt1:r1:0:cf26u" class="CreateQuoteBigButtonCell3">Product or service</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</a>
</td>
&#13;
我已经尝试过使用表ID来使用find_element_by_xpath,但它似乎无法正常工作,我还能看到其他任何选项吗?
我的代码目前看起来像这样:
browser.switch_to.frame(browser.find_element_by_css_selector("iframe[title='Quote Details']"))
clickExpPack = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="pt1:r1:0:cf16c1"]/tbody/tr/td')))
clickExpPack.click()
答案 0 :(得分:0)
尝试使用以下ModuleGraph
:
xpath
或
driver.find_element_by_xpath("//td[@class='CreateQuoteBigButtonCell3']").click()
或
driver.find_element_by_xpath("//td[@id='pt1:r1:0:cf16cl']").click()
如果这回答你的问题,请告诉我。