Forum Discussion

Vivek72's avatar
Vivek72
Contributor
10 years ago

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

 

  • Lage's avatar
    Lage
    10 years ago

    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) ?

    :(

     

  • william_roe's avatar
    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!");
                }
            }
    • Vivek72's avatar
      Vivek72
      Contributor

      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.

       

      • Vivek72's avatar
        Vivek72
        Contributor

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