无法检查注销按钮的注销按钮< href= "/index.php?r=site%2Flogout" ></a>此标记



我找不到该代码中<a href="/index.php?r=site%2Flogout"></a>的1个匹配节点。我尝试过://a[@href,'/index.php?r=site%2Flogout']这显示不正确。

此代码行<a href="/index.php?r=site%2Flogout"></a> xpath: //a[@href,'/index.php?r=site%2Flogout']的Xpath

将逗号,更改为相等的=

//a[@href='/index.php?r=site%2Flogout']

请尝试以下操作:

//a[包含(@href,'/index.php?r=site%2Flogout')]

正如你在我的应用程序中看到的那样,我有类似的外部html,这里我使用链接文本来点击它。你能尝试一下吗,让我知道它是否适合你。

a class="fxpage userpanel button"id="fxpage用户面板注销按钮"href="javascript:void(0);"onclick="showConfirm('您确定要注销吗?','http://asd/auth/logout?module=module')">注销

试试这个:

driver.findElement(By.linkText("注销")).click();