Forum Discussion

FabriceB's avatar
FabriceB
Occasional Contributor
10 years ago

javafx MenuButton : click on subelement

Hi,

 

I've a MenuButton on my application, under this MenuButton 2 elements to click. Actually, i can't found Elements to click on

 

By script :

I can MenuButton.DropDown => the list appears

I can find labels MenuButton.getItems().get(2).getText() => it s OK the correct label is returned

 

By KeywordTest :

A clic on a subelement on my MenuButton gives me another element

....java.contextmenu.scene31.pane.popupcontrolecssbridge.contextmenucontextmenubox.myelement

 

I can click on it, but a really want to control my elements, and i dont know if on a future release, the aliase will be correct

 

How can i found and CLick on sub element of this MenuButton by script ?

 

Thx a lot

 

Fabrice

4 Replies

  • djadhav's avatar
    djadhav
    Regular Contributor

    Please provide screenshots of what you're describing.

    • FabriceB's avatar
      FabriceB
      Occasional Contributor

      Hi,

       

      I give you two screenshots the ihm menu button and the object browser detect on TC

       

      thx

       

      Fabrice

      • TanyaYatskovska's avatar
        TanyaYatskovska
        Icon for Alumni rankAlumni

        Hi FabriceB,

         

        Try using the Point and fix mode of Object Spy to catch your elements. I suppose that they will be found in the ContextMenu object of your Java process. For example, here is what I see on my computer:

        Sys.Process("javaw").JavaFXObject("ContextMenu", "").
        JavaFXObject("Scene$3$1", "").
        JavaFXObject("ContextMenuContent$MenuItemContainer", "", 0).
        JavaFXObject("ContextMenuContent$MenuLabel", "Item1")

         Thus, the following code will click the target item:

        function Test()
        {
         var javaw;
         javaw = Sys.Process("javaw");
        
         javaw.JavaFXObject("Stage", "JavaFX").JavaFXObject("Scene", "").
        JavaFXObject("MenuButton", "MenuButton1").DropDown();
         javaw.JavaFXObject("ContextMenu", "").JavaFXObject("Scene$3$1", "").
        JavaFXObject("ContextMenuContent$MenuItemContainer", "", 0).
        JavaFXObject("ContextMenuContent$MenuLabel", "Item1").Click(); }