在MSCRM 2013的查找字段上执行Selenium自动化 [英] Doing Selenium Automation on Lookup Field of MSCRM 2013

查看:101
本文介绍了在MSCRM 2013的查找字段上执行Selenium自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在MSCRM的查找字段上执行硒脚本

I am Unable to execute the selenium script on lookup FIeld of MSCRM

我正在尝试从MSCRM 2011的查找列表中选择一个项目,这与下拉列表不同.如果单击查找字段上的查找图像,则将打开一个新窗口.在新窗口中,显示记录列表,用户必须通过单击对应的复选框来选择特定记录,然后单击确定"按钮.最后,所选记录将出现在查找"字段中.

I am trying to select an item from lookup list in MSCRM 2011, it is not like drop down list. If you click the lookup image on the lookup field then a new window will open. In the new window a list of records is displayed and user has to select the particular record by clicking on the check-box corresponding to it and then click OK Button. Finally the selected record will appear in Lookup field.

查找字段的DOM结构

<td class="Lookup_RenderButton_td" style="width: 21px">
<img id="customerid" class="ms-crm-ImageStrip-btn_off_lookup ms-crm-Lookup" defaultviewid="{A9AF0AB8-861D-4CFA-92A5-C6281FED7FAB}" savedquerytype="" isdisplayonly="false" resolveemailaddress="0" showproperty="1" disableviewpicker="0" disablequickfind="0" disablemru="0" allowfilteroff="1" autoresolve="1" defaulttype="1" lookupstyle="single" lookupbrowse="0" lookuptypeicons="/_imgs/ico_16_1.gif?ver=1287191314:/_imgs/ico_16_2.gif?ver=1287191314" lookuptypenames="account:1:Account,contact:2:Contact" crmattributeid="{09d25a7a-420f-42f7-bad4-192edc51356a}" lookuptypes="1,2" attrpriv="7" attrname="customerid" style="ime-mode:auto" req="2" alt="Click to select a value for Customer Name." src="/_imgs/btn_off_lookup.png" title="Click to select a value for Customer Name." forcesubmit="false">
<a tabindex="-1" onclick="Mscrm.Utilities.click(previousSibling);" href="#" title="Click to select a value for Customer Name."></a>
</td>

和下面是新建"窗口的DOM结构,其中包含一组CheckBoX记录

and Below is DOM Structure of New window which contains set of CheckBoX Records

<div>
<table id="gridBodyTable" class="ms-crm-List-Data" cellspacing="0" cellpadding="1" border="1" style="border-style:None;border-collapse:collapse;" summary="This list contains 50 Account records." primaryfieldname="name" tabindex="6" numrecords="50" oname="1" allrecordscounted="0" totalrecordcount="5000" morerecords="1" rules="rows">
<colgroup>
<thead>
<tbody>
<tr class="ms-crm-List-Row" otypename="account" otype="1" oid="{BF593B9E-E115-E511-8B6D-E4115BDF9DFD}">
<td class="ms-crm-List-NonDataCell" align="center">
<input id="checkBox_{BF593B9E-E115-E511-8B6D-E4115BDF9DFD}" class="ms-crm-RowCheckBox" type="checkbox" style=" " title=" MEXPrueba Compañia Número 1 " tabindex="6">
</td>

我是堆栈溢出的新手,因此无法上传问题图片.但是对于单击以查找"字段,我已在行下方写上了

I am new to stack overflow so can't Upload the Image of the Issue. But for Click to Lookup Field I have Written Below Line :

 driver.findElement(By.id("customerid")).click(); 

Below Lines are  for getting into new window
 driver.switchTo().defaultContent();
handles = driver.getWindowHandles();
         for(String hnd : handles)
         {
             if(!hnd.equals(handle))
             {
                 driver.switchTo().window(hnd);
             }
        }

System.out.println(driver.getTitle());

下面的行用于选择复选框

and Below Line is for selecting check box

driver.findElement(By.xpath("//table/tbody/tr[2]/td[1]/input")).click();

对于查找工作",您可以检查链接下方"

for Lookup Working you can check Below Link

推荐答案

让我们尝试了解自动执行查找所必须执行的操作,您可以做的第一件事是单击打开查找并选择第一个查找.但是,如果您的清单很长,则很难滚动&选择.我建议键入查询文本并移至其他字段,CRM将为您解决查询.

Let's try understand what you have to do to automate a lookup, first thing you can do is to click open the lookup and select the first one. But if you have a long list it's difficult to scroll & select. I suggest to type into the lookup text and move to the other field and CRM will resolve the lookup for you.

要进行查找,Xpath类似于此"//div[@id='new_lookupid']/div[1]",输入框为"//input[@id='new_lookupid_ledit']",您需要先执行Click& Hold然后放开&在输入内容之前,单击查找上的操作以获取带有尖号的输入框,如

For lookup the Xpath would be something like this "//div[@id='new_lookupid']/div[1]" and the inputbox as "//input[@id='new_lookupid_ledit']" you need to perform the Click&Hold then Release & Click action on the lookup to get the input box with a caret before you type into it, as

Actions action = new Actions(driver);

action.MoveToElement(driver.FindElement(By.XPath("//div[@id='new_lookupid']/div[1]"))).
ClickAndHold().Release().Click().Perform();

IWebElement typeIntoLookup= driver.FindElement(By.XPath("//input[@id='new_lookupid_ledit']"));

   //send keys        
       typeIntoLookup.SendKeys("ElementofLookup"); //the lookup text

我看到您正在用Java进行操作,并且上面的示例在C#中进行操作,因此希望语法有所不同,但是它在VS2015中对我有用,希望它对您有用.

I see you are doing it in java and the example above is in C# so expect the syntax differences, but it worked for me in VS2015 hope it works for you to.

这篇关于在MSCRM 2013的查找字段上执行Selenium自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆