Wednesday 15 April 2015

javascript - Java WebEngine.executeScript not working for forms or button clicks -


I'm trying to click on a button using Java FX class, web engine. I'm able to interact with the page to do other things, like read from the text box using the following:

  webEngine.executeScript ("document.getElementsByName (\" myText \ ") [0] .value = \" test \ ";); The above snippet works fine, but when I try to execute the three examples given below to press / button a form, nothing happens.  
  document.myForm.submit (); . Document.getElementById (\ "MyForm \") Deposit (); Click on document.getElementById ("theSubmitButton").   

Three of these three work when using the Firefox Web Console, but when I do them webengine Switch to exitscript ();

Could this be the reason for not working in Java WebEngineExuute Script () call?

Edit: Also, I know that the page has been loaded, I have already set something to wait for the page to load anything before calling.

EDIT2: Here are some more information about Java calls and results. When I call the line below:

  System.out.println (webEngine.executeScript ("document.getElementById ('thesubmitbutton'). Click ();"));   

I get the following results:

  undefined   

when I run it: < Pre> println (webEngine.executeScript ("document.getElementById ('theSubmitButton');"));

I get this result:

  [object HTMLInputElement]   

I know that the object exists , Where I think this is the issue. Click () Call. Then, the code below still works in Firefox's web console as shown below and does whatever I need it.

  document.getElementById ('thesubmitbutton').   

When I use the .click () function using the Java program (.executeScript (), the text of the button changes as I would in any web browser I see, but the actual redirection and form is deposited that I do not need. When I use the graphical web browser, it also does not work.

Form submission works everywhere (Firefox , Chrome, IE).

I have fixed this issue I

As it turns out, the text did not accumulate Price (in Textreria) as I expected when calling. Value = "whatever", he locked the browser. This firefox was handled very smoothly, but web engine did not.

It was actually stored on the reader (not the text design) Security was), and click to call. When () worked.

No comments:

Post a Comment