我需要使用Java selenium webdriver访问HTML的标题和子标题。能否说一下java代码访问HTML的标题和子标题。
<div class="containerShadowBottom"><div class="containerShadowRight">
<div class="containerShadowBL">
<div class="containerShadowUR">
<div class="containerShadowBR">
<div class="portletContent">
<h1 class="" id="Admin" style="cursor:pointer;" ondblclick="toggleClassName('AdminDiv','hide','detail',true);toggleClassName('AdminToggle','toggleUp','toggleDown');">
<a href="#" id="AdminToggle" class=" toggleDown" onclick="toggleClassName('AdminDiv','hide','detail',true);toggleClassName('AdminToggle','toggleUp','toggleDown');"></a>Admin</h1><div id="AdminDiv" class="hide">
答案 0 :(得分:1)
driver.findElement(By.xpath("//a[@id='AdminToggle']")).click();
或|
driver.findElement(By.id("AdminToggle")).click();