Forum Discussion

royd's avatar
royd
Regular Contributor
8 years ago
Solved

Trouble with XPath, need guidance

Trying to use XPath to click "Logout" (menu link). Here is what I have:

 

page = "*.imedconsent.com/THC*"
var logOut = page.FindChildByXPath("//a[@name='mainMenu_Logout']");
logOut.Click();

I am getting "JScript runtime error."

Line: 4 Column: 3

 

 

 

1. What does "Column: 3", how does TestComplete define Column?

2. What am I doing wrong?

  • I guess the problem is that page is a string, it must be a Page object:

    page = Sys.Browser().Page("*.imedconsent.com/THC*");

6 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    I guess the problem is that page is a string, it must be a Page object:

    page = Sys.Browser().Page("*.imedconsent.com/THC*");
    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      DOH!  Didn't catch that... yep, that would certainly do it.

    • royd's avatar
      royd
      Regular Contributor

      Thank you, Helen

       

      Thant was a silly oversight on my part! It works as expected!

       

      robert, I should have posted the entire message. I'm sure you would have caught it! The error message was:

       

      Microsoft JScript runtime error.

       

      Object doesn't support this property or method.

       

      Error location:

      Unit: AtHome Smoke ...

      Line: 8 Column: 3.

       

      I was in a hurry. :)

       

      That bring me to the next question. What does Column 3 mean? 3 characters, 3 words, 3 words + space?! I always wonder! Can anyone clear that up for me?

       

      Thanks.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Three characters... so, basically, starting at the beginning of the line and starting with 0, count the characters... column 3 is the 4th character on line 8.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What's the additional info on your runtime error?  There should be additional text on it.  Of the code you posted, what is Line 4?

     

    I'm GUESSING... that the problem is in the line that reads logOut.Click();.  I'm guessing that, what happened is that the logOut option was not found and so it returned something like "Object does not support this method" or something like that.  This could be a timing issue where some action happening before this is refreshing the page and, at the time your code is called, the logOut link isn't available.  Try putting a breakpoint on your code and step through it slowly.  If it works that way, you might want to look at building in some wait detection to make sure that the page objects are ready for interaction before you do so.