Forum Discussion
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
- ameykhopade8 years agoContributor
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.
- AlexKaras8 years agoChampion Level 3
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-action-page-object.html : "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-attributes.html.
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.
- ameykhopade8 years agoContributor
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
- baxatob8 years agoCommunity Hero
Try to locate your target element using XPATH
- ameykhopade8 years agoContributor
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.
Related Content
- 5 years ago
- 8 years ago
Recent Discussions
- 8 hours ago