Ask a Question

QuerySelector() method is not in my project. How do I get it?

SOLVED
mikej411
Occasional Contributor

QuerySelector() method is not in my project. How do I get it?

Hello my company is using TestComplete. I recently started automating Web apps. Up until now, I used the Object Spy to map all elements on a web page. I need to use a CSS selector. I have tried to access the QuerySelector method in my script but it looks like it is not there.

 

When I run the following line:

okButton = webPage.QuerySelector("#cmdOkBtn");

 

It results in the following:

Unable to find the object QuerySelector("#cmdOkBtn"). See Additional Information for details.

The object with the specified attributes does not exist.

 

I know the ID i entered on my web page exists, as I can access it in the DOM. When I type "webPage." and then hit Ctrl+SpaceBar, the code completion window does not include QuerySelector in its list of methods. This is why I think it is not there. Is this an extension that needs added?

2 REPLIES 2
mikej411
Occasional Contributor

***************DISREGARD ORIGINAL POST AND SEE BELOW****************

 

So apparently I dont know how the QuerySelector method works. I thought it worked the same way as the Find method.

 

For example, when I want to map a label, the Find method works like this:

warningLabel= webPagePanel.Find("objectIdentifier", "MainContent_NotificationText", 100, true);

 

When I try to map that same object using the QuerySelector method, it does not work:

warningLabel= webPagePanel.QuerySelector("#MainContent_NotificationText");

 

I try to use that QuerySelector warningLabel after the QuerySelector line above (For example, warningLabel.Click), the test then fails and the log says "Object Required". So apparently it didnt find my object

 

What am I doing wrong? How exactly can I use the QuerySelector method for a simple mapping of label as shown above?

 

The label in question has the below HTML.

INPUT "name=ctl00$MainContent$NotificationText" id="MainContent_NotificationText" type=hidden value="To save a partial filter set for this report, the required fields identified above must not be blank."

 

mikej411
Occasional Contributor

Never mind. I have found the answer. It just didnt like when I used a nameMapping object as the prefix. For example

 

webPagePage = Aliases.iexplore.IELOA

IELOA.QuerySelector()

 

Instead I had to use an object on the page first.

 

I dont know why though

 

cancel
Showing results for 
Search instead for 
Did you mean: