Forum Discussion

Udayreddy_90's avatar
Udayreddy_90
Contributor
13 years ago

Find link in the tabel/Page

What is the wrong in this code. I am unable to click on the the specified link in the Table.\

How to use Find Object here?

In this case which is most suitable url? ( url1 or url2)






Sub Test

  Dim url, page, props, values, link



  url1 = "C:\Documents and Settings\kalyan.urimi\Desktop\child.html"

  url2 = "file:///C:/Documents%20and%20Settings/kalyan.urimi/Desktop/child.html"

  set page = Sys.Process("iexplore").Page("*").Table(0)



  ' Specify the sought-for properties and values

  props = Array("tagName", "innerText")

  values = Array("A", "This is a link1")



  ' Find an object that corresponds to the specified criteria

  Set link = page.FindChild(props, values)

  link.Click



End Sub

7 Replies

  • Hi,


    Specify Depth = 1 in your FindChild method:

    Set link = page.FindChild(props, values, 1)


    As far as I can see, your tested web page's hierarchy is as follows: sys--process--page--table--links, and your script searches among the page object's children. Since you didn't specify the depth in your FindChild method, it uses the default value (0). This value means that FindChild searches only among the page's direct children. When you specify Depth = 1, FindChild will search in child and grandchild objects of the page - and it will find your links.


    In this case which is most suitable url? ( url1 or url2)


    I guess, it does not matter for your script since you are using the Page("*") notation. However, check how your browser represents the needed URL and use it in your tests.


    I hope this helps.

    Ann

  • Ok, Its working.......

    But,

    In my test hierarchy is

    Sys -- iexplore -- page -- table -- cell - link

    This table contains 3 rows and 3 columns and each cell contains one link ( with same inner Text, outer Text )



    I used Name Mapping, in that I mapped up to table object.

    I want to click on the link which is present in 2 row 3 column cell . How can I do this with using mapped Objects?




  • Hi,


    Could you please attach here a screenshot of your Name Mapping scheme?


    Thanks in advance.

    Ann

  • I need to click on the link which is present in 2nd row 2column.

    Screen shorts are attached bellow.

     
  • Hi,


    I guess, your script should be something like this:


    Call Sys.iexplore.pageChild.table.cell.linkThisIsALink6.Click


    By the way, try to inspect your tested web page in the Object Browser. You can select the needed mapped object in the object tree, find the appropriate method and check its syntax. Please find the attached screenshot that illustrates what I meant.


    Ann

  • Call  Sys.iexplore.pageChild.table.cell.linkThisIsALink6.Click

                I am not interested to add all the the links to my test.



    My requirement is like this

                Mapped the names up to table, this some thing link this in the Aliases window as  Aliases.iexplore.pageChild.table

                If I say row no. and column no Then click on that link in the table.

               
  • Hi,


    Well, you need to combine the Name Mapping functionality with the function from which we start the conversation. I guess, it should be something like this:







    ...


      props = Array("tagName", "innerText")

      values = Array("A", "This is a link6")

     ' Find an object that corresponds to the specified criteria

      Set link = Aliases.iexplore.pageChild.table.FindChild(props, values, 10)

      link.Click


    ...





    I hope this helps.




    Ann