我有一个简单的点击按钮的问题。它的按钮是CSS。Selenium WebDriver - 没有这样的元素:无法找到元素
<div id="rightBtn">
<input type="submit" class="mainButton" id="dodajTrenera" value="Dodaj" name="dodaj_trenera">
</div>
我想执行的点击动作,我用这个代码:
WebElement addTrainer = driver.findElement(By.name("dodaj_trenera"));
addTrainer.click();
我得到错误:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"dodaj_trenera"}
为什么我得到这个错误?它应该工作完美。 此按钮位于网页的底部。也许我应该向下滚动页面?
你可以检查元素是否在iframe中吗?谢谢。 – alecxe