我嘗試這個xpath,但我不知道如何繼續? 我在彈出菜單中2個對象,我想選擇頁面中的第一個找不到xpath使用硒的元素
的HTML是:
</div>
<input class="sprite form-enter" type="submit" value="" name="wobi">
</div>
<div class="container">
<img src="/_media/home/img/icons/pension.png">
<div class="login-text-container">
<a class="sprite form-enter" href="https://pension.wobi.co.il/login" value="" name="pension" type="submit"></a>
</div>
</div>
的Java代碼:
driver.findElement(By.xpath("//input[@class='sprite form-enter' and input//@name='wobi']")).click();
Thread.sleep(2000);
的代碼執行後我得到以下異常:
線程「main」中的異常org.openqa.selenium.NoSuchElementException:no such el ement:無法找到元素:{「method」:「xpath」,「selector」:「//輸入[@ class ='sprite form-enter'並輸入/ @ name ='wobi']」}
我的代碼有什麼問題?
你的意思是你有相同的類'精靈外形enter'和名稱'wobi'二元? –
您的XPath錯誤更好嘗試並檢查它是否可以在Firebug/Firepath中使用 –