Selenium webdriver用于访问HTML中的标头和子标头的Java代码

时间:2014-02-20 06:11:37

标签: java selenium selenium-webdriver

我需要使用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">

1 个答案:

答案 0 :(得分:1)

driver.findElement(By.xpath("//a[@id='AdminToggle']")).click();

或|

driver.findElement(By.id("AdminToggle")).click();