I’m trying to run the line of code below in my script, but I get an error saying that more than one object with these properties was found on the page.
Browser("browser").Page("page").WebElement("css:=.normalDayOfMonth").Click
So, I tried adding an index, as shown below:
Browser("browser").Page("page").WebElement("css:=.normalDayOfMonth", "index:=0").Click
But now it’s not detecting any object at all. Could anyone help me out with this? Thanks!
Edit: For anyone else who comes across this, it turned out I was using QTP10 and as Motti pointed out below, CSS and Xpath support was only added in QTP11.
The support for using
CSSandXPathto identify test objects was added in QTP11, in your comments you say that you’re using QTP10 which would explain why you’re facing problems…What’s probably happening is that QTP is ignoring
cssas an unrecognizd property so your description matches all elements and then when you addindex:=0it brings one of the invisible elements (e.gHEADorHTML) which can’t be clicked.If all you’re trying to do is match the
classNameyou can use QTP’sclassidentification property("class:=normalDayOfMonth").BTW the
Highlightfunction is an undocumented function similar to the object repository’s highlight functionality and can be very useful in troubleshooting tests.