kpinnisetti
11 years agoContributor
Selecting drop down values by keys method
Hi, Dropdowns are not recognized by test complete so i wanted to use keys method to select a particular value by its content text and by keys method. In our dropdown list we have Sales and Non Sales values. when i'm trying to execute the below query even the content text is Sales it's skipping and executing the else part. Am i missing any thing in my if statement?
Sub test
Set clickPosCatdd = Aliases.ddEmpTermPosCat
clickPosCatdd.Click
If Aliases.ddEmpTermValPosCategory.innerText = "Sales" then
Set clickddValue = Aliases.ddEmpTermValPosCategory
clickddValue.Keys ("[Enter]")
log.message("Non Sales is not clicked")
else
Set clickddValue = Aliases.ddEmpTermValPosCategory
clickddValue.Keys ("[Down]")
clickddValue.Keys ("[Enter]")
log.Message("Non Sales is clicked")
End If
Sub test
Set clickPosCatdd = Aliases.ddEmpTermPosCat
clickPosCatdd.Click
If Aliases.ddEmpTermValPosCategory.innerText = "Sales" then
Set clickddValue = Aliases.ddEmpTermValPosCategory
clickddValue.Keys ("[Enter]")
log.message("Non Sales is not clicked")
else
Set clickddValue = Aliases.ddEmpTermValPosCategory
clickddValue.Keys ("[Down]")
clickddValue.Keys ("[Enter]")
log.Message("Non Sales is clicked")
End If
- I would add a log message
Log.Message Aliases.ddEmpTermValPosCategory.innerText
to confirm that the text is actually "Sales" during the test run in case it is blank or there is something unexpected like an extra space character.
You could also try entering the first character of the list item if that works
clickddValue.Keys ("S") to enter sales or
clickddValue.Keys ("N") to enter non sales