Ask a Question

Click method not accepted in chrome

SOLVED
Vivek72
Contributor

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']")

                                               ' OR

Set acceptbtn = cell.FindChildByXPath("//SPAN[@onclick='inlineGridEditor.saveItem(0)']")

Call acceptbtn.Click

 

html is something like this:

<td role="gridcell">
        <span class="command icon-accept-inv" onclick="inlineGridEditor.saveItem(0)"></span>
        <span class="command icon-cancel-inv" onclick="inlineGridEditor.cancelEditItem(0)"></span>
    </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,&quot;&quot;, 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.

 

Thanks

 

11 REPLIES 11
william_roe
Super Contributor

I've had to write code around browser types when using 'FindChildByXPath'. Mostly due to how our UI vendor (DevExpress) renders controls differently. I don't know if this helps or not. So far I've not had to delineate between FireFox and IE. I don't know if this will help but thought I would throw it out there just in case.

 

        if (0 == aqString.Compare(page.Parent.ProcessName, "chrome", false))
            obj = page.FindChildByXPath("//table[@id='tlEmployeeSiteAccess']//input[@id='SiteAccess" + AccessType[i] + "_" + SiteAccess[i] + "_S']", true);
        else
            obj = page.FindChildByXPath("//table[@id='tlEmployeeSiteAccess']//span[@id='SiteAccess" + AccessType[i] + "_" + SiteAccess[i] + "_S_D']", true);

        if (obj != null) {
            //Log.Picture (obj.Picture(), "image");
            //ShowMessage(obj.FullName);
            // clicks radio button
            try {
                obj.Click();

            } catch (e) {
                Log.Error("Error clicking item!");
            }
        }

Hi william. Sorry but I am not expert and so could not quite understand why you had different attributes for different browsers. If thats the way it works then I have applied that in my code and it doesnt work. It even throws exception that Picture method doesnt work for the object in consideration. If there is something I got totally wrong then please correct me. Thank you for your reply.

 

I am still seeking help on the above issue. Could anyone have any suggestions please..

I think that your problem is not with the Click operation. Your problem is with the way you mapped the object.

 

Can you share with us the Tree of the icon you want to map? (Object Browser tab)

 

Without seen the tree i just can recomend you to map the table. Inside the table map the icons enabling the Extended Find property. Highlight the objects to ensure that TestComplete is able to locate them properly. 

 

regards

Lage

 

Hello Lage

 

The problem here is that the icon element is not shown or identified by the object browser. Even the Object spy identifies the cell and not the icons that are child elements of it. I got access to those icons through html. It returns exists as true if I pass the checkpoint and can successfully click on them in IE. The problem only comes in chrome. Through some research in the other blogs I understood that onclick action is having some issues in chrome so I am assuming there is way out for this tried by other members or by our experts.

 

Please find attached the object hierarchy.

 

Thanks

Any tips on the above issue? Still awaiting response.

 

Thank you.

Hi,

I'm afraid, if the object browser is not recognizing the icons it will be hard click on them. Maybe you can clic on relative coords to the cell. 

Are you sure that your icons are int the selected cell (0,3 ) instead of cel (0,2) ?

😞

 

Hi Lage,

 

Thanks for response. I appreciate your simple answer that made me work hard to solve the problem. 

Your question: Are you sure that your icons are in the selected cell (0,3 ) instead of cel (0,2) ?

My Answer: Yes, the icons were in the cell(0,3).

 

Your suggestion: Maybe you can click on relative coords to the cell. 

My Solution: Yes, that works. The icons where accessible as HTML child elements but Click method was available in all the browsers except Chrome. I had to use 'offset.Width' & 'offset.Height' values to find the coordinates of the icons and click in the cell on those icons in the Chrome browser. This worked only for Chrome and could not be able ot click on the icon in the other browsers. So, I had to use conditional statement to make Click method browser specific.

It was the case of simple solution but I was going through all but right direction.

 

Thanks a lot.

 

 

 

somethimes there is no way and we have to use ungly thinks like that hehe...good job!

cancel
Showing results for 
Search instead for 
Did you mean: