Forum Discussion

Iso_Yura's avatar
Iso_Yura
Contributor
11 months ago

Test execution fails after I modified variable of a ClickButton operation.

I need to modify my test that it selects button in ClickButton operation by using a variable. 

When I created keyword test in Value column the value displays as "...". I want to 

 

After I changed it to a variable and used "MappedName" value of the button from Object Spy window. I use DB Table as a variable.

 

I'm wondering what will happen when I change the Value using variable to let's say ToolButton5, but in the Item column it will be still ToolButton2? If it says ToolButton2 in the Item column does that mean it will always look for ToolButton2 even when the value will use as variable ToolButton5.

Then I run the test it fails, when it gets to the step where it should click on the button after I changed from "..." to the variable the error details say: "Exception. Type mismatch".

 

 

What can cause this error? 

 

 

18 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    If I understand correctly, you have declared the following,

    ProjectSuite.Variables.Config_DDL_Meteor["TC_Chip_button"] = "Aliases.IsoSpeak.MainOptionsModule.centralWidget.uiLayoutWidget.NewProjectMenuModule.Widget3.Widget.ToolButton2"

    and you are trying to perform a click button like so,

    ClickButton(ProjectSuite.Variables.Config_DDL_Meteor["TC_Chip_button"])

     which will not work.

     

    • Iso_Yura's avatar
      Iso_Yura
      Contributor

      ProjectSuite.Variables.Config_DDL_Meteor["TC_Chip_button"] 

      is a DB Table type variable, and I see that it's not working. In all other tests DB Table variable works fine for different operations.

      This is what I want to figure out where is the issue and how can I make it works.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    This is what the script code looks like for your scenario,

     

    function HighlightButtons()
    {
        // URL: https://www.w3schools.com/bootstrap/bootstrap_buttons.asp
        var btn1 = 'Sys.Browser("chrome").Page("https://www.w3schools.com/bootstrap/bootstrap_buttons.asp").Panel("belowtopnav").Panel(0).Panel("main").Button(0)';
        var btn2 = "Aliases.panelMain.buttonDanger";
        var btn3 = "Aliases.panelMain.buttonDefault";
        var btn4 = "Aliases.panelMain.buttonInfo";
        var btn5 = "Aliases.panelMain.buttonLink";
        
        Sys.HighlightObject(btn1); // Error: Type mismatch.    
        Sys.HighlightObject(eval(btn1));
        Sys.HighlightObject(eval(btn5));
    }

     

    Whether using the full name (btn1) or the alias name (btn5), using eval function evaluates JavaScript code represented as a string and returns its completion value. The source is parsed as a script.

     

    Notice that the first Sys.HighlightObject throws an error.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The button that you are clicking on, is it a tool bar? What is the value of your project variable? Do you want to click the button based on the project variable value?

    • Iso_Yura's avatar
      Iso_Yura
      Contributor

      I'm using test suite variable, and this is the value which I'm using: "Aliases.IsoSpeak.MainOptionsModule.centralWidget.uiLayoutWidget.NewProjectMenuModule.Widget3.Widget.ToolButton2" in DB Table.

      No it's not a tool bar, it's a button that makes a selection of the project type.

       

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    What is the value of ProjectSuite.Variables.Config_DDL_Meteor["TC_Chip_button"] ?

     

     

    • Iso_Yura's avatar
      Iso_Yura
      Contributor

      This is the value: 

      "Aliases.IsoSpeak.MainOptionsModule.centralWidget.uiLayoutWidget.NewProjectMenuModule.Widget3.Widget.ToolButton2"

      When I use object spy and select this button this is what TC displays. I don't know what other value can be used.

    • Iso_Yura's avatar
      Iso_Yura
      Contributor

      When open Operation Parameters of the ToolButton2 this is what values it has. 

       

      It doesn't contain any actual values of the button.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The variable ProjectSuite.Variables.Config_DDL_Meteor["TC_Chip_button"] has the value of "Aliases.IsoSpeak.MainOptionsModule.centralWidget.uiLayoutWidget.NewProjectMenuModule.Widget3.Widget.ToolButton2" ?

     

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    So if the variable ProjectSuite.Variables.Config_DDL_Meteor["TC_Chip_button"] has the value assigned "Aliases.IsoSpeak.MainOptionsModule.centralWidget.uiLayoutWidget.NewProjectMenuModule.Widget3.Widget.ToolButton2".

     

    What are you trying to do with ProjectSuite.Variables.Config_DDL_Meteor["TC_Chip_button"]?

    • Iso_Yura's avatar
      Iso_Yura
      Contributor

      The idea is that "Aliases.IsoSpeak.MainOptionsModule.centralWidget.uiLayoutWidget.NewProjectMenuModule.Widget3.Widget.ToolButton2" value = ToolButton. 

      I have 2 buttons and I want to use the same test where I can click two different buttons. I will store the buttons value in ProjectSuite.Variables.Config_DDL_Meteor["TC_Chip_button"] DB Table.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I think I'm starting to understand the problem you are having. You have a table that has e.g. ToolButton2, ToolButton1, ToolButton3 etc. and you want to perform a click button action based on the value received from the table i.e. ToolButton2.ClickButton()

     

    Similar to the code example,

    Aliases.IsoSpeak.MainOptionsModule...Widget.ToolButton2.ClickButton()
    Aliases.IsoSpeak.MainOptionsModule...Widget.ToolButton1.ClickButton()
    Aliases.IsoSpeak.MainOptionsModule...Widget.ToolButton3.ClickButton()

     

    You can use eval() function to evaluate JavaScript code represented, which means creating a function and calling the code from your keyword test.

    • Iso_Yura's avatar
      Iso_Yura
      Contributor

      Yes, that's exactly what I want! My test should create 6 different projects, where each project is == to a different button("Aliases.IsoSpeak.MainOptionsModule.centralWidget.uiLayoutWidget.NewProjectMenuModule.Widget3.Widget.ToolButton2"), in total there are 6 buttons. So, I will have 6 lines with values in my DB Table, later I plan to make it data driven loop.

       

      I never used  eval()  will check it now.

    • Iso_Yura's avatar
      Iso_Yura
      Contributor

      I found that I can do it under Operation Parameters:

       

      This is how my test step looks like(it's a different button, but concept is the same):

       

       

      When I run it I keep getting an Exception error: "Unable to evaluate the operation's "Shift" parameter. Error: RuntimeError: The specified object is not indexable"

       

    • Iso_Yura's avatar
      Iso_Yura
      Contributor

      Also, I just found in TC documentation that Shift is a button:

      Parameters

      The method has the following parameter:

      Shift

      Specifies the key that will be pressed during the click. See TShiftKey.

       

      Now I'm confused, can I even use a variable for ClickButton operation if it refers to a key not to the object?

       

      From documentation: "You can click a button by simulating keystrokes that represent an access key. An access key is an underlined symbol within the button caption. It permits a click of a button by pressing the ALT key in combination with the assigned access key. For example, if the underlined symbol is F, you should simulate pressing the ALT+F key combination (for detailed information about simulating keystrokes, see the Simulating Keystrokes topic)."

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I don't understand why you are using Shift, and I don't know if ClickButton accepts any parameters.

     

    This is the reason I'm not able to provide a proper solution, because it's confusing!

     

     

    • Iso_Yura's avatar
      Iso_Yura
      Contributor

      I'm not using a Shift, it's by default. I just showed here that TC uses key as a value, maybe it accepts only key as value for this operation.

      I was using a variable and when I was using a variable it didn't work because of Exception - Type mismatch.

       

       Maybe this is a reason why it says "Type mismatch." because variable is a different type.

      I can't find any information. I created TC support ticket yesterday about this, but didn't get a respond yet.