cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Select matching value from a dropdown in assertion condition

SOLVED
Highlighted
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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Unable to Select matching value from a dropdown in assertion condition

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

View solution in original post

2 REPLIES 2
Highlighted
Community Hero

Re: Unable to Select matching value from a dropdown in assertion condition

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

View solution in original post

Highlighted
Community Manager

Re: Unable to Select matching value from a dropdown in assertion condition

Thank you for the great explanation tristaanogre. 

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


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Compare images using the Region Checkpoint

See replies!

Converting UTC TimeDate in an Excel file

See replies!

Compare HTML table with Excel file and correct data in Excel file

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!
Top Kudoed Authors