Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
2 years ago

Javafx webview controls

Hi,

 

Our developer has implemented a username and password fields into javafx webview. I have enabled all available controls in my project properties but I am not able to get access to the fields inside webview.

 

Any help would be really appreciated.

 

Thanks

TestQA

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Here's and example of using getEngine() on JavaFX WebView

     

    • TestQA1's avatar
      TestQA1
      Frequent Contributor

      great thanks very much, I will give it a go. I was missing to use getDocument which I realized after I posted here.

       

       

    • TestQA1's avatar
      TestQA1
      Frequent Contributor

      Thanks Marsha. I will try and tell you if that works!

      • TestQA1's avatar
        TestQA1
        Frequent Contributor

        Hi Marsha,

         

        I tried that link and it is very useful. However, I am facing issues setting value in the field.

        When I type 'engine. ' it shows all the supported methods, but when I type 'ele. ' it doesn't show any method. So, I enter setAttributes and when I run the script it says Cannot setAttribute of null.

        Any idea what's causing it?

         

        function test() {

        var engine =  address.getEngine();
        var ele = engine.getDocument().getElementById("username");
        ele.setAttribute( "value", "abc");
        }

         

        Thanks

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Try to create a new project, record your actions using keyword test, then convert your keyword test to script. Have a look at the script generated, and how TC has identified the control in the name mapping.

     

    If TC has identified the control correctly, you should then be able to copy what has been generated into your project.

    • TestQA1's avatar
      TestQA1
      Frequent Contributor

      Hi rraghvani thanks. I knew how  to use keybaord shortcuts to input details but I also want to understand how webengine works. 

  • TestQA1's avatar
    TestQA1
    Frequent Contributor

    Great thanks very much. I will give it a go. I was missing to add getDocument to access html page.

     

  • TestQA1's avatar
    TestQA1
    Frequent Contributor

    Looks like I'm getting too overwhelmed with this issue 🙂 I did use getDocument() if you check my previous replies where I have shared the code. I think the problem is with the selector 'id' , not sure why. Can you check the html code I shared and help me identify if I am using the correct id. Also, if I can use xpath instead as I know exactly what the xpath is.

     

    Thanks

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      I noted in rraghvani 's code that he used getElementsByName() (note bolded 's') to find single element by name.

      Maybe you should use getElementsById() instead of getElementById() ?

      As it was mentioned in some reply in the initial threads provided by Marsha_R, try to check the documentation as for what methods are provided by the getDocument() FX object.