Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

JavaScriptExecutor doesn't seem to have an 'executeScript' feature #51

Copy link
Copy link
@hammondreg

Description

@hammondreg
Issue body actions

I'm trying to access my own banking details (not other peoples!) by clicking on the 'Continue' button of:

https://onlinebanking.nationwide.co.uk/AccessManagement/IdentifyCustomer/IdentifyCustomer

but without success. I have tried a normal 'click()' on the button, but nothing happens no matter how long I wait.

I have already successfully used Selenium in a .Net program to overcome this problem, and whilst the Selenium version (in C#) also seems to ignore a 'click()', when I use:

JavaScriptExecutor.ExecuteScript("arguments[0].click();", targetButton);

it does have the required effect, i.e. the button 'clicks' and I transfer to the next html page so all is good.

Using a similar approach with 'htmlunit-android' however, there doesn't seem to be an extension 'executeScript' that I can use with 'JavaScriptExcutor'. Have I missed something? Is it there under another guise??

Here's the Kotlin snippet (sorry its not Java, but I have to use Kotlin because Java doesn't support co-routines):

import org.htmlunit.javascript.background.JavaScriptExecutor
import org.htmlunit.WebClient
import org.htmlunit.html.HtmlButton
import org.htmlunit.html.HtmlPage
    
private lateinit var mainScreen : HtmlPage

var webClient = WebClient()     // Create the webClient
var myURL = "https://onlinebanking.nationwide.co.uk/AccessManagement/IdentifyCustomer/IdentifyCustomer"

var mainPage = webClient.getPage(myURL) as HtmlPage        // Retrieve the target page

var jsexecutor: JavaScriptExecutor = webClient as JavaScriptExecutor    // Declare a JS executor
        
var buttonsList = mainPage.getElementsByTagName("button") as List<HtmlButton> // Find all 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) // <= 'executeScript'!! isn't there!
         }
}

Thanks in advance for any assistance

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.