Forum Discussion

kavansays's avatar
kavansays
Contributor
10 years ago
Solved

Finding Background Color in javaFX object Table.

Hello Folks,

 

We are trying to automate JAVAFX Application where we are not able to identify the color of the selected row of the JAVAFX object Table.

 

Below is the sample code snippet that i tried..

 

'----- TestComplete V10.5, VB Script : Application: Desktop: JAVAFX ------------------
Set javaw = Aliases.javaw
Set oTable = javaw.MainWnd.scene.PrimaryTab.TradesTable

sColor = oTable.getBackground.BACKGROUND_COLOR.property.value
'-------------------------------------------------------------------------------------

Also tried many other combination of methods and properties with no luck !

 

Have anyone faced this issue before? or someone from the smartbear suggest the solution would be a great help !!

 

Cheers !!

Kavan Shah

 

  • Maybe the row's .getBackground().fills.get(index).fill object is what you need?

    ' Get selected row index
    rowIndex = oTable.getSelectionModel().getSelectedIndex()
    
    ' Get the row object
    Set oRow = oTable.JavaFXObject("TableRow", "", rowIndex)

    ' Index 0 seems to be row border color, 1 - row background color, but results may vary Set oFill = oRow.getBackground().fills.get(1).fill strColor = oFill.toString().OleValue ' RGBA ??? Call Log.Message(strColor) r = Round(oFill.getRed() * 255) g = Round(oFill.getGreen() * 255) b = Round(oFill.getBlue() * 255) Call Log.Message(aqString.Format("R: %i G: %i B: %i ", r, g, b))

2 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Maybe the row's .getBackground().fills.get(index).fill object is what you need?

    ' Get selected row index
    rowIndex = oTable.getSelectionModel().getSelectedIndex()
    
    ' Get the row object
    Set oRow = oTable.JavaFXObject("TableRow", "", rowIndex)

    ' Index 0 seems to be row border color, 1 - row background color, but results may vary Set oFill = oRow.getBackground().fills.get(1).fill strColor = oFill.toString().OleValue ' RGBA ??? Call Log.Message(strColor) r = Round(oFill.getRed() * 255) g = Round(oFill.getGreen() * 255) b = Round(oFill.getBlue() * 255) Call Log.Message(aqString.Format("R: %i G: %i B: %i ", r, g, b))
    • kavansays's avatar
      kavansays
      Contributor

      Helen, Thanks a Ton!!

       

      This code is working absolutely fine, this is exactly what i wanted..

       

      Many Thanks,

      Kavan Shah 


      HKosova wrote:

      Maybe the row's .getBackground().fills.get(index).fill object is what you need?

      ' Get selected row index
      rowIndex = oTable.getSelectionModel().getSelectedIndex()
      
      ' Get the row object
      Set oRow = oTable.JavaFXObject("TableRow", "", rowIndex)

      ' Index 0 seems to be row border color, 1 - row background color, but results may vary Set oFill = oRow.getBackground().fills.get(1).fill strColor = oFill.toString().OleValue ' RGBA ??? Call Log.Message(strColor) r = Round(oFill.getRed() * 255) g = Round(oFill.getGreen() * 255) b = Round(oFill.getBlue() * 255) Call Log.Message(aqString.Format("R: %i G: %i B: %i ", r, g, b))