Java 使用xpath定位元素并单击它
使用带java的selenium时,不能点击按钮。如何使用xpath定位元素并单击它 以下是我正在使用的源页面的一部分:Java 使用xpath定位元素并单击它,java,selenium-webdriver,Java,Selenium Webdriver,使用带java的selenium时,不能点击按钮。如何使用xpath定位元素并单击它 以下是我正在使用的源页面的一部分: <div id="top-navigation"> <ul class="menu"> <li class="item first active"> <a href="/index.php/sprachen-lernen/englisch">Home</a></li> <li class="item
<div id="top-navigation">
<ul class="menu">
<li class="item first active">
<a href="/index.php/sprachen-lernen/englisch">Home</a></li>
<li class="item ">
<a href="/index.php/openArea/school">Online Language School
</a></li>
<li class="item ">
<a href="/index.php/openArea/partner">Enterprise Solutions
</a></li>
<li class="item ">
<a href="/index.php/openArea/customer">References
</a></li>
<li class="item last ">
<a href="/index.php/openArea/contact">Contact</a></li>
</ul>
<div id="login-button">
<a href="/login/login"><img src="/images/openArea/login.png" alt="Login" /></a>
</div>
</div>
但是它没有点击按钮。这是我第一次尝试使用selenium,请有人指导我,我的语句有什么错误,或者如果我想使用xpath,那么确切的语句应该是什么?我已经使用firebug找到元素的xpath,现在它可以工作了:)
driver.findElement(By.id("login-button")).click();