Forum Discussion

kaiiii's avatar
kaiiii
Regular Contributor
5 years ago

Unable to Select matching value from a dropdown in assertion condition

I am comparing excel sheet value with a object value, but I need to check matching value and then  select item from dropdown.

I am using below assertion code

 

Avaiable_Option_List = Project.Variables.AMS_Customer("Avaiable Option")&"*"

so here, use that highlighted logic to check value match or not.

condition is like i am check If( Customer1234 = Customer* )

so here if Customer match only then it should proceed other wise fail

Set AvailableOption = page.FindChildByXPath("//select[@id='ddlSizesAvailable']")
For i = 0 to AvailableOption.wItemCount-1 Step 1
If(Avaiable_Option_List = AvailableOption.wItem(i)) Then
    AvailableOption.Click
    AvailableOption.Keys(AvailableOption.wItem(i))
   Log.Message("Available Option: "&AvailableOption.wItem(i))
   Exit For
End IF
Next
End IF

  • I'm assuming that you are comparing are strings.  So, I would use an aqString.Contains to see if the one object contains the text of the other.  You can't compare "customer1234" to "customer*" as strings because, as strings, they don't match.  But you CAN do

     

    aqString.Contains('customer1234', 'customer') and, if it returns anything other than -1, than they "match".

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I'm assuming that you are comparing are strings.  So, I would use an aqString.Contains to see if the one object contains the text of the other.  You can't compare "customer1234" to "customer*" as strings because, as strings, they don't match.  But you CAN do

     

    aqString.Contains('customer1234', 'customer') and, if it returns anything other than -1, than they "match".

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Thank you for the great explanation tristaanogre. 

      Hi kaiiii , did this solve the issue for you?