I cannot seem to find anything which lets me progress from this stumbling block, as there doesn’t appear to be an ‘execute’ in JavaScriptExecutor. All suggestions as how I might overcome this gratefully received:
Snippet in Kotlin not Java (sorry):
import org.htmlunit.javascript.background.JavaScriptExecutor
import org.htmlunit.WebClient
import org.htmlunit.html.HtmlAnchor
import org.htmlunit.html.HtmlPage
private lateinit var mainScreen : HtmlPage
var webClient = WebClient() // Create the webClient
var mainPage = webClient.getPage(anyURL) as HtmlPage // Retrieve a target page
var jsexecutor: JavaScriptExecutor = webClient as JavaScriptExecutor // Declare a JS executor
var buttonsList = mainPage.getElementsByTagName("button") as List<HtmlButton> // Find all the buttons
for (targetButton in buttonsList ) // Loop round the buttons
{
if (targetButton.textContent == "Continue") // This is the one I'm looking for
{
jsexecutor.executeScript("arguments[0].click();", targetButton) // No 'executeScript'!! =:-{
}
}
and in app:build.gradle.kts I have this defined:
implementation(group="org.htmlunit", name="htmlunit3-android", version="4.3.0")
Thanks again for any help