Ask a Question

Unable to Select matching value from a dropdown in assertion condition

SOLVED
kaiiii
Regular Contributor

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

2 REPLIES 2
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".


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
sonya_m
SmartBear Alumni (Retired)

Thank you for the great explanation tristaanogre. 

Hi @kaiiii , did this solve the issue for you? 


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: