无法在python selenium webdri中单击或展开+image按钮

2024-09-30 01:26:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图展开+按钮来展开它下面的选项,但无法展开,pythonide抛出下面的错误。尝试了不同的CSS和xpath,但没有成功:(

错误消息:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath",

Firefox XPath:

.//*[@id='ExcentiveTreeViewn0']/img

以下html代码:

<table cellspacing="0" cellpadding="0" style="border-width:0;">
    <tbody>
            <tr>
                <td>
                    <a id="ExcentiveTreeViewn0" href="javascript:TreeView_PopulateNode(ExcentiveTreeView_Data,0,document.getElementById('ExcentiveTreeViewn0'),document.getElementById('ExcentiveTreeViewt0'),null,'r','<span class=\'nodeCss\' onclick=\"LoadPage(\'grids%252fgrid_folders.aspx%253fid_node%253dTzlq3UXxbAE%253d%2526id_table%253d-301%2526id_mod%253dTzlq3UXxbAE%253d\', \'iGrid\');\"><img class=\'nodeIcon\' src=\"../style/-1/treeview/picto_folder.gif\" /><span class=\'nodeText\'>Rules</span></span>','-300#-301#0#staticNode#0#culture#F','f','','f')">
                        <img style="border-width:0;" alt="Develop" src="../style/-1/treeview/rplus.gif"/>
                    </a>
                </td>
                <td class="" style="white-space:nowrap;" onmouseout="TreeView_UnhoverNode(this)" onmouseover="TreeView_HoverNode(ExcentiveTreeView_Data, this)">
            </tr>
    </tbody>
</table>

Tags: idimgstyle错误tableelementwidthxpath
2条回答

不要用句点开头xpath

//a[@id='ExcentiveTreeViewn0']/img

其他选项:

  1. 代码在iFrame中,因此您需要先切换到它。在
  2. 解析器中的selenium令人困惑。里面嵌入了很多HTML代码。在

请编辑问题,使其包含您正在尝试的代码以及HTML的较大部分

在路由到正确的IFrame并使用下面链接中提到的action类之后,问题得到了解决

链接:Unable to perform click action in selenium python

相关问题 更多 >

    热门问题