2014-03-04 2 views
0

내가 셀레늄을 사용하여 해당 id 특성을 기반으로 폼에서 특정 텍스트 상자를 선택하려면 원하는.셀렌 찾아 <textbox><table td>

코드 아래에서 시도했지만 "ID를 찾을 수 없습니다 ..."오류가 발생했습니다.

WebDriverWait waitt = new WebDriverWait(driver, 120); 
waitt.until(ExpectedConditions.visibilityOfElementLocated(By.id("leadCaptureList_leadCapture_firstName"))); 

WebElement query = driver.findElement(By.xpath("//* [@id='leadCaptureList_leadCapture_firstName']"));` 

과 같은 시도를했지만 여전히 운이 없었습니다.

셀렌에 중첩 된 텍스트 상자 요소를 선택하는 데 필요한 것이 있습니까?

http://my.jetscreenshot.com/demo/20140304-c1dk-105kb.jpg (이미지를 확대하려면 Ctrl + 누름) 여기 (이미지의) 이미지는 내 페이지의 HTML 구조입니다. 이 이미지에서 나는 목표로 삼고있는 텍스트 상자를 강조 표시했습니다. 거의 실패하지 않아야 id 속성을 가진 텍스트 상자를 찾기

<table id="page-container" border="0" cellpadding="0" cellspacing="0" width="100%"> 

<tbody><tr> 
    <td id="page-header"> 

<div id="top"> 

<div id="page-title" class="limiter clear-block"> 

<div id="header-top"> 

<div id="logo"><img id="logo-image" alt="Home" src="images/logo.png"></div> 

<div id="header-right"> 

<div id="block-ad" class="block block-ad"> 

<div class="block-content clear-block "> 



</div> 

</div> 



<div id="header-links"> 

<!-- added table for structure --> 

<table style="display:block; float:right;" class="norubik" border="0" cellpadding="1" cellspacing="0" width="100%"> 

<tbody><tr> 

<td align="center"><font color="#666"><a href="/user" style="color: red;font-size:10px;font-family:Verdana;color:#666;text-decoration: none">My Account </a> | <a style="color: red;font-size:10px;font-family:Verdana;color:#666;text-decoration: none" href="/logout">Logout</a></font></td> 

</tr> 

<tr> 

<td align="center"> 

<span class="username"><!--Logged in as--> <strong>admin</strong> 

<!-- Code for image --> 

<div style="position:relative; top:2px; left:0px;"> 





    <img src="images/premier_small.png"> 







</div> 

</span> 

</td> 

</tr> 

</tbody></table> 

</div> 









</div> 

</div> 

<div style="width: 100%; clear: both; text-align: left; margin-bottom: 6px; height:30px;"> 


<!-- begin menu div --> 

<div class="AJXCSSMenuGdPbSLD"><!-- AJXFILE:ajxmenu.css --> 

<div class="ajxmw"> 

<div class="ajxmw2"> 

<ul> 



    <li style="position: static;" class=""><a class="ajxsub" href="/" title="Home"><b>Home</b> 

    </a> 

    <div style="display: none;" class="ajxdd"> 

    <div class="ajxsbg"> 



    </div> 

    </div> 

    </li> 



    <li style="position: static;" class=""><a class="ajxsub" href="/node/3111" title="Getting Started"><b>Getting Started</b> 

    </a> 


    </li> 



    <li style="position: static;" class=""><a class="ajxsub" href="/node/2962" title="Training"><b>Training</b> 

    </a> 

    <div style="display: none;" class="ajxdd"> 

    <div class="ajxsbg"> 



    <ul> 



     <li style="position: static;" class=""><a class="ajxsub" href="/faq" title="FAQ">FAQ</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/node/3431" title="Video Tutorials">Video Tutorials</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/node/3138" title="Training Webinars">Training Webinars</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/pub/training-schedule" title="Training Schedule">Training Schedule</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/node/3735" title="Internet Marketing Webinars">Internet Marketing Webinars</a></li> 



    </ul> 



    </div> 

    </div> 

    </li> 



    <li style="position: static;" class=""><a class="ajxsub" href="/reseller/ir/leadCaptureList" title="Leads"><b>Leads</b> 

    </a> 
    </li> 



    <li style="position: static;" class=""><a class="ajxsub" href="/node/2964" title="Affiliate"><b>Affiliate</b> 

    </a> 

    </li> 



    <li style="position: static;" class=""><a class="ajxsub" href="/catalog/179" title="Store"><b>Store</b> 

    </a> 

    <div style="display: none;" class="ajxdd"> 

    <div class="ajxsbg"> 



    <ul> 



     <li style="position: static;" class=""><a class="ajxsub" href="/catalog/179" title="Memberships">Memberships</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/catalog/219" title="Marketplace">Marketplace</a></li> 



    </ul> 



    </div> 

    </div> 

    </li> 



    <li style="position: static;" class=""><a class="ajxsub" href="/" title="Resources"><b>Resources</b> 

    </a> 

    <div style="display: none;" class="ajxdd"> 

    <div class="ajxsbg"> 



    <ul> 



     <li style="position: static;" class=""><a class="ajxsub" href="/node/3017" title="Support">Support</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/reseller/calendar" title="Calendar/Events">Calendar/Events</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/node/3440" title="Documents">Documents</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/node/17" title="Documents">Documents</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/reseller/ir/contactInfo" title="Upline Report">Upline Report</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/node/3353" title="Feature Comparison">Feature Comparison</a></li> 



     <li style="position: static;" class=""><a class="ajxsub" href="/node/3497" title="Developer (API)">Developer (API)</a></li> 



    </ul> 



    </div> 

    </div> 

    </li> 







</ul> 

</div> 

</div> 

</div> 

<!-- end menu div --></div> 

</div> 



<div id="branding"> 

<div class="limiter clear-block"> 

<div class="breadcrumb clear-block"><span class="breadcrumb-link"><a href="/">LeadOutcome</a></span> <span class="breadcrumb-link"><a href="leadCaptureList.action">Leads</a></span> <span class="breadcrumb-link"><a href="leadCaptureList.action">Manage Leads</a></span> </div> 

</div> 

</div> 

</div> 






    </td> 
    </tr> 


    <tr> 
    <td id="content-container"> 

     <div id="page" class="clear-block page-content"> 

    <div id="content"> 
     <div class="content-wrapper clear-block"> 

<table border="0" cellpadding="0" cellspacing="0" width="100%"> 
    <tbody><tr> 
     <td class="bhdr-container"><span class="bhdr"> Manage Leads </span></td> 
    </tr> 
</tbody></table> 
<span style="color: blue; font-weight: bold"></span> 
<span style="color: red; font-weight: bold"></span> 


<form id="leadCaptureList" name="leadCaptureList" action="leadCaptureList.action" method="post"> 
<div><input name="advanceSearchClicked" value="No" id="advanceSearchClicked" type="hidden"> 

    </div><table class="wwFormTable"> 
    <input name="leadsToTransfer" value="" id="leadsToTransferId" type="hidden"> 
    <input name="deleteids" value="" id="leadCaptureList_deleteids" type="hidden"> 
    <input name="leadOrIR" value="Lead" id="leadCaptureList_leadOrIR" type="hidden"> 
    <input name="savedSearchCriteria.searchName" value="" id="leadCaptureList_savedSearchCriteria_searchName" type="hidden"> 
    <input name="savedSearchCriteria.published" value="" id="leadCaptureList_savedSearchCriteria_published" type="hidden"> 
    <input name="leadSearchName" value="" id="leadCaptureList_leadSearchName" type="hidden"> 
    <input name="cfValuesFromSessOrDB" value="false" id="leadCaptureList_cfValuesFromSessOrDB" type="hidden"> 

    </table><table class="hdr-section-search" border="0" cellpadding="0" cellspacing="0"> 
     <tbody><tr> 
      <td>&nbsp;</td> 
     </tr> 
     <tr> 
      <td> 
      <table style="background-color: #F8F8F8" class="conbox4" border="0" cellpadding="2" cellspacing="0" width="100%"> 
       <tbody><tr> 

        <th colspan="4"><font size="2">Search Options (Search criteria can be combined)</font></th> 
        <th colspan="6" align="right"> 
         <select id="currentlyOwnedLeads" name="currentlyOwnedLeads"> 

          <option value="All">All leads </option> 

          <option value="No">Show all leads ever owned by me </option> 
          <option value="Yes">Show only leads currently owned by me </option> 
         </select> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
         <input name="" value="All" id="currentlyOwnedIdUsedForJavascript" type="hidden"> 
        <input name="coForManageLeads" id="selectedSalesRepCo" value="" type="hidden"> 
        <input name="id" value="" id="leadCaptureList_id" type="hidden"> Sales Rep: <span id="selectedIrCompany"></span> <a href="javascript:void()" id="searchIrButton"><img src="images/btn_find_IR.png" border="0"></a></th> 

        <th colspan="3" align="center"> 
        <span onmousemove="ddrivetip(receiveSummaryMouseover,150)" onmouseout="hideddrivetip()">Receive Lead Summary:<select name="receiveLeadManagementSummaryEmails" id="summaryMailsField" onchange="setReceiveLeadManagementSummaryEmails();"> 
    <option value="false">No</option> 
    <option value="true" selected="selected">Yes</option> 


</select> 
</span> 
        </th> 
       </tr> 


       <tr> 
        <td align="right">Lead Id:</td> 
        <td><input name="leadIdForSearch" maxlength="7" value="" id="leadCaptureList_leadIdForSearch" style="width:80px" type="text"></td> 
        <td align="right">First Name:</td> 
        <td><input name="leadCapture.firstName" value="test Lo" id="leadCaptureList_leadCapture_firstName" style="width:80px" type="text"></td> 
        <td align="right">Last Name:</td> 
        <td><input name="leadCapture.lastName" value="" id="leadCaptureList_leadCapture_lastName" style="width:80px" type="text"></td> 
        <td align="right">Email:</td> 
        <td><input name="leadCapture.email" value="" id="leadCaptureList_leadCapture_email" style="width:80px" type="text"></td> 


        <td align="right">Phone No.:</td> 
        <td><input name="leadCapture.phone" value="" id="phoneNo" style="width:80px" type="text"></td> 
        <td align="right">Status:</td> 
        <td><select name="leadCapture.status" id="leadCaptureList_leadCapture_status"> 
    <option value="">-- Select Status --</option> 
    <option value="New">New</option> 
    <option value="Converted">Converted</option> 


</select> 

        </td> 

       </tr> 




       <tr id="advancedSearchRow1" style="display: none"> 
         <td align="right">Company:</td> 
        <td><input name="leadCapture.company" value="" id="leadCaptureList_leadCapture_company" style="width:80px" type="text">  </td> 

        <td align="right">Address:</td> 
        <td><input name="leadCapture.address" value="" id="leadCaptureList_leadCapture_address" style="width:128px" type="text"></td> 

        <td align="right">City:</td> 
        <td><input name="leadCapture.city" value="" id="leadCaptureList_leadCapture_city" style="width:122px" type="text"></td> 
         <td align="right">State:</td> 
        <td><select name="leadCapture.state" id="leadCaptureList_leadCapture_state"> 
    <option value="">-- Select State --</option> 
    <option value="AK">Alaska</option> 



</select> 

        </td> 
         <td align="right">Zip Code:</td> 
        <td><input name="leadCapture.zip" value="" id="leadCaptureList_leadCapture_zip" style="width:80px" type="text"></td> 

       </tr> 
       <tr id="advancedSearchRow2" style="display: none"> 
        <td align="right">Lead History:</td> 
        <td><input name="leadCapture.leadHistory" value="" id="leadCaptureList_leadCapture_leadHistory" style="width:80px" type="text"></td> 

        <td align="right">Category:</td> 
        <td><select name="leadCapture.leadCategory.id" id="leadCategorySearch1" style="width:122px"> 
    <option value="0" selected="selected">All Leads</option> 
    <option value="2">Business Leads</option> 
    <option value="200">Webinar Follow up 12/4</option> 


</select> 
</td> 

        <td align="right">Custom Field Type:</td> 
        <td><select name="leadCapture.leadTypeObj.id" id="leadTypeId" style="width:122px" onclick="disableLeadType()" onchange="showCustomFields();"> 
    <option value="0" selected="selected">-Select Type-</option> 
    <option value="16">Contacts</option> 
    <option value="139">ZMS: How can we help you?</option> 
    <option value="178">Gita</option> 
    <option value="206">111 test</option> 


</select> 
</td> 


        <td align="right">Interest :</td> 
        <td><input name="leadCapture.interest" value="" id="leadCaptureList_leadCapture_interest" style="width:80px" type="text"> 
        </td> 
        <td align="right">Score :</td> 
        <td colspan="2"> 
        <select name="scoreLogicalOperator" id="leadCaptureList_scoreLogicalOperator"> 
    <option value="greater" selected="selected">Greater than</option> 
    <option value="less">Less than</option> 
    <option value="equal">Equal to</option> 


</select> 

        &nbsp; 
        <input name="serachByleadScore" value="" id="leadCaptureList_serachByleadScore" style="width:80px" type="text"> 
        </td> 

       </tr> 

       <tr id="advancedSearchRow3" style="display: none"> 
        <td align="right">Lead Source:</td> 
        <td><input name="leadCapture.leadSource" value="" id="leadCaptureList_leadCapture_leadSource" style="width:80px" type="text"></td> 

        <td align="right">Ad Code:</td> 
        <td><input name="leadCapture.adCode" value="" id="leadCaptureList_leadCapture_adCode" style="width:80px" type="text"></td> 

        <td colspan="8" align="right"></td> 

       </tr> 


       <tr> 
        <td colspan="3" align="right" width="250px;"> 

        <img src="images/btn_m_save_search.png" id="saveLeadSearchId" onclick="return popUpForSaveLeadSearch();" align="absmiddle" border="0"> 
         <select name="savedSearchCriteria.id" id="leadCaptureList_savedSearchCriteria_id" onclick="disableLeadSearch()" onchange="return selectSearchCriteriaByName();"> 
    <option value="-1" selected="selected">--Select a search--</option> 


</select> 
</td> 
        <td colspan="6"><input style="display: none;" value="Delete Search" onclick="return deleteLeadSearchData();" id="deleteSearchButton" type="button"></td> 

        <td id="tdForAdvancedSearch" align="right"><a href="javascript:advancedSearch()" id="advancedSearchLink"><img src="images/btn_m_show_advanced.png" border="0"></a> 
        </td> 

        <td colspan="3" align="right"><input alt="true" src="images/btn_search.png" id="leadCaptureList_searchBtn" name="searchBtn" value="true" onclick="$('#pageNumber').val(1);return validSearchField();" type="image"> 

        &nbsp;<input alt="Submit" src="images/btn_m_clear_search.png" id="leadCaptureList_0" value="Submit" onclick="clearAllSearchFields();" type="image"> 
</td> 

       </tr> 


      </tbody></table> 
      </td> 
     </tr> 
    </tbody></table> 
    <div id="customFieldsDiv"></div> 
    <input name="noOfLeadsToBeDisplayed" value="250" id="noOfLeadsToBeDisplayedId" type="hidden"> 
    <input name="pagination" value="" id="pagination" type="hidden"> 
    <input name="pageNumber" value="1" id="pageNumber" type="hidden"> 
    <input name="backButton" value="false" id="backButton" type="hidden"> 
    <input name="nextButton" value="false" id="nextButton" type="hidden"> 
    <input name="saveSearchFlag" value="false" id="leadCaptureList_saveSearchFlag" type="hidden"> 

    </form></div> 

</div></div></td></tr></tbody></table> 
+0

어떤 도움이 가능하다 :

당신은 WebDriver는 다음과 같이 대기하고 작동하는지 확인 EXPLICT 시도 할 수 있습니다? 위의 질문에 명확하지 않으면 – obama

+0

_Never_ 이미지로 게시물 코드를 알려주십시오. 아무도 이런 것을 재현 할 수 없습니다. 코드가 질문에 넣기에 너무 큰 경우 질문에 관련 부분을 넣고 [Gist] (https://gist.github.com/) 또는 원하는 모든 부분에 넣으십시오. –

+1

id 속성이있는 텍스트 상자는 중첩 된 요소 든 중첩되지 않은 요소 든간에 차이를 만들지 않습니다. 페이지가 렌더링 될 때 텍스트 상자가 보이나요? 아니면 역동적입니까? –

답변

0

아래 코멘트에 제안

html 코드. Selenium이 있다면 거기에있을 것입니다. findElement 명령이 실행될 때 DOM에 요소가 없거나 표시되지 않는 경우 Selenium에서 예외가 발생합니다.

WebElement textBox = (new WebDriverWait(driver, 10)) 
    .until(ExpectedConditions.visibilityOfElementLocated(By.id("leadCaptureList_leadCapture_firstName"))); 
+0

생성 된 HTML 코드에서이 텍스트 상자 ID가로드되고 표시되는지 확인했습니다. 그러나 왜 그것이 선택하지 않는지. 어떠한 제안? – obama

관련 문제