Click method not accepted in chrome
I am trying to click buttons (accept icon, delete icon, etc., ) which are child elements of a grid cell but is not identified by object browser. However, I found access to them by using Xpath expression and passing Click command on them. This works fine on IE but throws exception on chrome (This method doesnt support the method or property).
My code is something like this:
Set grid = page.Find("className","k-widget k-grid*",1000)
Set cell = grid.Find(Array("RowIndex","ColumnIndex"),Array("0","3"),1000)
Set acceptbtn = cell.FindChildByXPath("//SPAN[@class='command icon-accept-inv']")
Set acceptbtn = cell.FindChildByXPath("//SPAN[@onclick='inlineGridEditor.saveItem(0)']")
html is something like this:
<span class="command icon-accept-inv" onclick="inlineGridEditor.saveItem(0)"></span>
<span class="command icon-cancel-inv" onclick="inlineGridEditor.cancelEditItem(0)"></span>
<span data-edit-off="" class="command icon-edit-inv" onclick="inlineGridEditor.editItem(0)" style="display: none;"></span><span data-delete="" class="command icon-del-inv" onclick="inlineGridEditor.deleteItem(0,"", urls.DeleteCallCategory)" style="display: none;"></span></td>
The button element is identified both in chrome and IE with the above script but Click action works only on IE.
Solved! Go to Solution.
Even i have similar problem in clicking the buttons in span elements.i'm working in Chrome browser.
I can able to find those buttons through "FindChildByXpath() and EvaluateXpath() methods " but throws back an error while clicking those buttons as "Click is not a function".
So Please suggest a way to resolve this issue.
As it has been noted several times on this forum, search by XPath is the worst approach in TestComplete's world and should be used only when nothing else works.
One of the reasons for this is that (as it is noted in the documentation) search by XPath may return either object that is wrapped (supported) by TestComplete or native DOM object.
.Click() (with the capital 'C') is the wrapping method provided by TestComplete. Obviously, it is inaccessible for native DOM elements.
The generic approach if searching UI elements by XPath:
-- Search for the element;
-- If the element was found, check whether the native DOM element or the element wrapped by TestComplete was returned (to do this, you can check if some property specific to TestComplete (e.g. .Exists one) is supported with the help of the aqObject.IsSupported() function);
-- If the returned object is supported by TestComplete, you can use both TestComplete-specific and provided by DOM methods;
-- If the returned object is a native one, only native DOM methods (with some possible limitations) can be used in test code.
/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.