I am Unable to execute the selenium script on lookup FIeld of MSCRM
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 Structure of Lookup FIeld
<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>
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
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.
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, asI 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.