Same title question already exists, however the environment seems to be different.
I'm trying to execute Spring Boot Web MVC test using MockMvc and WebDriver, so I don't need to run Selenium Server.
I created sample project on GitHub as public repository.
I try to impelent the code referencing Spring Framework Document and Spring Boot Document.
The test code works when using MockMvc and HtmlUnit (MessageControllerMockMvcAndHtmlUnitTest.java). However, when I execute the test using MockMvc and WebDriver (MessageControllerMockMvcAndWebDriverTest.java), the error occurs as follows:
java.lang.IllegalStateException: Unable to locate element by name for com.gargoylesoftware.htmlunit.TextPage@~
Does anyone know what is wrong and how to fix it?
I finally solved the problem by myself.
I just made 2 mistakes.
I misstyped the URL (messages
not messagges
)
I tried to operate hidden element. So I need to operate by JavaScript.
this.id.sendKeys(id);
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
javascriptExecutor.executeScript("document.getElementById('id').value = '" + id + "';");