Forum Discussion

twhitehouse's avatar
twhitehouse
Contributor
9 years ago

click check box find by span

I need to click a check box on the web ui in my automation project using Test Complete.  I was able to map the all of the check boxes on the page correctly in Name Mapping.  But, when the script runs, Test Complete can no longer find any of the check boxes. 

 

One thing I found interesting was that the check box I wanted had a property of being in row "1" instead of row "0" when I did an edit in Test Complete to try and change some of the properties Test Complete had found in the Name Mapping.  I believe this is occurring because there are 2 buttons on the page that toggle a view back and forth without refreshing the whole page.  Also, there are check boxes that show up for different items depending on which of those 2 buttons was selected by the user.  So, I am guessing that those check boxes are part of an array, but only 1 out of the 2 sets of them show up at any one time based upon which button was selected at the top of the page by the user.  I believe this is what is giving Test Complete some problems as it can not find the check boxes upon execution of the script.  I know that was a lot of detail, but hopefully I have been clear enough without writing a book.

 

Anyways, a colleague suggested I do a find by child or by xpath.  I have tried the below:

 

Here is my code snippet:

 

        Dim object_x
        
        object_x =  Aliases.browser.pageEnroll.EvaluateXPath("//[@id='my_table']/tbody/tr/td[1]/span[starts-with(@class, 'glyph glyphs row')]/@class")
      
        object_x(0).Click 

 

----------------

 

But, Test Complete throws an error on the "click" line saying:

 

"Microsoft VBScript runtime error.  Type mismatch: 'object-x'".....

 

----------------

 

I gathered the xpath by doing the following.  I did an inspect element on the check box in Google Chrome.  Here was the xpath I copied from developer tools in Chrome:

 

//*[@id="my_table"]/tbody/tr/td[1]/span

 

  Next, I copied the xpath in Chrome and pasted it into my script.  I had to change the double quotes to single quotes and remove the leading "*" before "[@id" as I did not think the "*" was needed ( although maybe I am wrong? ).

 

I know also that I can do a check to see if the item exists as I found that on one of the other pages while searching.  But, that should not help me here as if the item exists, the click should just work.  The item also should exist on the page, so that should not be the issue.  I believe one of a few things to be my problem.  But, I do not know how to fix them if they are the problem:

 

1. Am I incorrectly referring to "Aliases.browser.pageEnroll" instead of something like "page"?

2. Is my xpath incorrect as far as Test Complete is concerned?

3. Is "[starts-with" still even used.  I found this from Test Complete 8.5 which is many versions ago.  Maybe this is deprecated now?

4. I am not using my variable in a legal way.  Maybe what gets returned from EvaluateXPath is not something in which I can put ".Click" at the end of it?  Maybe its a different object type or data type?  How can I tell what is being returned?  Can I attach ".Click" to the end of my variable "object_x"?

 

Useful pages so far:

https://support.smartbear.com/viewarticle/71392/

http://community.smartbear.com/t5/Functional-Web-Testing/SPAN-tag-without-text/td-p/56203

http://support.smartbear.com/viewarticle/70020/#_ga=1.125109898.1868987023.1441391324

 

No RepliesBe the first to reply