Ask a Question

how Can i get the gylphicon class element which I am not able to spy

ameykhopade
Contributor

how Can i get the gylphicon class element which I am not able to spy

I need to perform a click action on a glyphicon class element which I am not able to spy.

the element  which I want to click is the pencil icon in the cell.(attached Image pencil.pgn)

 

As I said I am not able to spy this element and I am using a data driven framework where I need the objects full name to perform a click action.

 

I tried getting the object item for the pencil icon using the Queryselector method on the cells fullname which should be the parent item of the pencil icon.

 

this is what i am seeing when I inspect the pencil icon

Inpect.PNG

 

so I tried using the class on the object of the cell 

Sys.Process("iexplore").Page("*").Form("aspnetForm").Panel("divHeaderAndContent").Panel("contentWrapper").Panel(0).Panel(0).Panel(2).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Table(0).Cell(2, 4).QuerySelector(".glyphicon")

 

this gave me an empty object.

 

and when I am using the class name as  ".glyphicon glyphicon-pencil pointer" i am getting error as missing ')'.

 

what am I missing here ? am I doing this correctly ?

 

any alternative to click the pencil icon which is not spy able using the object spy as I need the full name of that object to perform any action.

 

Thanks,

amey

 

 

 

8 REPLIES 8
Marsha_R
Community Hero

Take a look at this old thread and see if the code at the very bottom helps you:

 

https://community.smartbear.com/t5/TestComplete-Functional-Web/Click-empty-span-elements/td-p/90354


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

yes I tried that but i am not getting any object in return when I execute this 

 

Sys.Process("iexplore").Page("*").Form("aspnetForm").Panel("divHeaderAndContent").Panel("contentWrapper").Panel(0).Panel(0).Panel(2).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Table(0).Cell(2, 4).QuerySelector("span.glyphicon glyphicon-pencil pointer")

 it this correct because i am getting an object when i evaluate this but I am not able to inspect that object.

please see attach image in that image we can see object as Result but the Inspect button is disabled not sure why and not able to check what I am getting.

not sure how can I get the Xpath in IE.

but tired to use NativeWebObject.Find method but that is also not working 

 

I tried

Sys.Process("iexplore").Page("*").Form("aspnetForm").Panel("divHeaderAndContent").Panel("contentWrapper").Panel(0).Panel(0).Panel(2).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Table(0).Cell(2, 4).NativeWebObject.Find("tooltip","Edit","span")

but this is also not returning anything for some values it gives me an object which is empty thats probably because it was not able to fine that object.

and some times it gives me an object but the Inspect button is disabled in the evaluate window not sure why I am getting this.

 Do I need to install some drivers or anything else .

 

And agian for query selector method I tried to run the example provided by smartbear which is

Sub Test
  Dim TestedPage, CSSSelector, res

  Browsers.Item(btChrome).Run("https://smartbear.com/")
  Set TestedPage = Sys.Browser("*").Page("https://smartbear.com/")

  CSSSelector = "div#main-nav" 
  
  ' Call the function
  Set res=TestedPage.QuerySelector(CSSSelector)
  ' Check the result
  If Not res Is Nothing Then
      ' If the element was found, output its HTML code
      Log.Message(res.outerHTML)
  Else
      ' If the element was not found, post a warning to the log
      Log.Warning("The element was not found.")
  End If
End Sub

 but this is also not working and i am getting the message as element was not found mesasge. 

here also the res is returning and object whose Inspect Button is disabled in the Evaluate window when I try to evaluate the res.

 

You can build XPATH using FireFox+FirePath. Then try it with IE.

Also note, that QuerySelector() method applies to Page object. 

 

So try something like:

 

Sys.Process("iexplore").Page("*").QuerySelector(".glyphicon")

Hi Amey,

 

>  it this correct because i am getting an object when i evaluate this but I am not able to inspect that object.

I think that what you do is correct and you are getting expected result.

As per http://support.smartbear.com/testcomplete/docs/reference/test-objects/members/page/queryselector-act... : "If there is no matching TestComplete test object, the method returns the appropriate HTML object." So, as TestComplete does not 'see' this glyph object (it is absent in the Object Browser), the native HTML object is returned. Obviously, it cannot be inspected in TC's debugger, but I am pretty sure that it is possible to call its native methods as described here: http://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/accessing-native....

So you need to check (ask developers) if the found element has a native method like .click() that can be called to emulate the click on it (I believe that vm.action() should be called but confirm this with developers). Otherwise, you will need to find its (absolute) coordinates and perform coordinate-based click using TestComplete means.

 

P.S. http://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/javascript.html provides an info on how to execute script from web page - it might help to properly call vm.action() method.

 

P.P.S. However, I think that all from above overcomplicates your task and coordinate-based click within the proper table cell will be stable and reliable enough.

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

Hi Apologies for late reply.

 

you are right it is giving me the HTML object and cant be inspected.

I wasn't able to call the native method (vm.action() ) but i am able to now call the click method with the correct syntax.

 

the correct syntax to click the object is :

Sys.Process("iexplore").Page("*").Form("aspnetForm").Panel("divHeaderAndContent").Panel("contentWrapper").Panel(0).Panel(0).Panel(2).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Table(0).Cell(2, 4).QuerySelector("span.glyphicon.glyphicon-pencil.pointer").Click()

 this is working for me.

here I calling the QuerySelector Method on its immediate parent which is detected by object spy and supports the QuerySelector method.

 

 

The co-ordinate logic would have not worked in my case as the position of the edit img varies in the table cell.

 

thanks,

Amey 

 

cancel
Showing results for 
Search instead for 
Did you mean: