Assistance with a dynamically generated field - selenium

I have another dynamic question for you. I have three input fields that I need to enter values for. These "dijit_form_DateTextBox_36" are created dynamically (the 36 is variable). There is a value earlier in the code that is unique and can be searched for. I know I need to use something like:
driver.findElement(By.xpath("//div[contains(., 'QA GM 04012014 1424 Item Name')]/parent::...somepath.sendKeys("...");
But I am still too new to this stuff to be able to figure it out. And if someone can assist me with what I need to put, as well as how they figured it out, I would greatly appreciate it. I'd really love to solve these on my own! Code is below. Bolded portion is the static text that can be searched. Bolded and italicized lines are the three controls that need to be modified. NOTE: The id="shipDate0_0" is also dynamic, it can be shipDate0_0, shipDate1_0, etc. So can't key on that.
<tr class="tableControlHeader twTableHeaderTR"></tr>
<tr class="tableControlDataRow evenRow twTableTR">
<td class="twTableTD details" align="center" rowspan="2"></td>
<td class="twTableTD details" align="center" rowspan="2">
<p>
<b>
QA GM 04012014 1424 Item Name
</b>
</p>
<br></br>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
</td>
<td class="twTableTD" align="center" rowspan="2"></td>
<td class="twTableTD" align="center"></td>
<td class="twTableTD" align="center"></td>
<td id="shipDate0_0" class="twTableTD" align="center">
<div style="padding-right: 20px;">
<div id="dateWrap-projectedFirstShipDate_0_0" class="inputText_Full twControl twDateSelector" ;="" onblur="updateAvgPerWeek(0,0)" initialvalue="" value="" name="tw#local#quoteComparison#0#country#0#projectedFirstShipDate" style="white-space:nowrap;">
<div id="projectedFirstShipDate_0_0" lang="" dojoattachpoint="pickerDiv" widgetid="projectedFirstShipDate_0_0" name="tw#local#quoteComparison#0#country#0#projectedFirstShipDate">
<span dojoattachpoint="leftPicker">
<div id="widget_dijit_form_DateTextBox_36" class="dijit dijitReset dijitInlineTable dijitLeft dateSelectionSin…tBox dijitComboBox dijitDateTextBox dijitComboBoxOpenOnClick" role="combobox" widgetid="dijit_form_DateTextBox_36">
<div class="dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer" role="presentation" dojoattachpoint="_buttonNode, _popupStateNode" popupactive="true"></div>
<div class="dijitReset dijitValidationContainer"></div>
<div class="dijitReset dijitInputField dijitInputContainer">
<input id="dijit_form_DateTextBox_36" class="dijitReset dijitInputInner" type="text" aria-haspopup="true" role="textbox" dojoattachpoint="textbox,focusNode" autocomplete="off" aria-valuenow="null" aria-invalid="false" tabindex="0" value="" style="" delocalized="null" aria-disabled="false"></input>
<input type="hidden" value=""></input>
</div>
</div>
</span>
<span dojoattachpoint="rightPicker"></span>
<span style="position: absolute;" dojoattachpoint="calImage"></span>
<input id="projectedFirstShipDate_0_0" type="text" isdatefield="true" name="tw#local#quoteComparison#0#country#0#projectedFirstShipDate" style="display:none" dojoattachpoint="hiddenInput" delocalized="null"></input>
</div>
</div>
</div>
</td>
<td id="InDate0_0" class="twTableTD" align="center" ;="" onclick="updateAvgPerWeek(0,0)">
<div style="padding-right: 20px;">
<div id="dateWrap-inDate_0_0" class="inputText_Full twControl twDateSelector" ;="" onblur="updateAvgPerWeek(0,0)" initialvalue="" value="" name="tw#local#quoteComparison#0#country#0#inDate" style="white-space:nowrap;">
<div id="inDate_0_0" lang="" dojoattachpoint="pickerDiv" widgetid="inDate_0_0" name="tw#local#quoteComparison#0#country#0#inDate">
<span dojoattachpoint="leftPicker">
<div id="widget_dijit_form_DateTextBox_35" class="dijit dijitReset dijitInlineTable dijitLeft dateSelectionSin…tBox dijitComboBox dijitDateTextBox dijitComboBoxOpenOnClick" role="combobox" widgetid="dijit_form_DateTextBox_35">
<div class="dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer" role="presentation" dojoattachpoint="_buttonNode, _popupStateNode" popupactive="true"></div>
<div class="dijitReset dijitValidationContainer"></div>
<div class="dijitReset dijitInputField dijitInputContainer">
<input id="dijit_form_DateTextBox_35" class="dijitReset dijitInputInner" type="text" aria-haspopup="true" role="textbox" dojoattachpoint="textbox,focusNode" autocomplete="off" aria-valuenow="null" aria-invalid="false" tabindex="0" value="" style="" delocalized="null" aria-disabled="false"></input>
<input type="hidden" value=""></input>
</div>
</div>
</span>
<span dojoattachpoint="rightPicker"></span>
<span style="position: absolute;" dojoattachpoint="calImage"></span>
<input id="inDate_0_0" type="text" isdatefield="true" name="tw#local#quoteComparison#0#country#0#inDate" style="display:none" dojoattachpoint="hiddenInput" delocalized="null"></input>
</div>
</div>
</div>
</td>
<td id="OutDate0_0" class="twTableTD" align="center" onclick="updateAvgPerWeek(0,0)">
<div style="padding-right: 20px;">
<div id="dateWrap-outDate_0_0" class="inputText_Full twControl twDateSelector" ;="" onblur="updateAvgPerWeek(0,0)" initialvalue="" value="" name="tw#local#quoteComparison#0#country#0#outDate" style="white-space:nowrap;">
<div id="outDate_0_0" lang="" dojoattachpoint="pickerDiv" widgetid="outDate_0_0" name="tw#local#quoteComparison#0#country#0#outDate">
<span dojoattachpoint="leftPicker">
<div id="widget_dijit_form_DateTextBox_34" class="dijit dijitReset dijitInlineTable dijitLeft dateSelectionSin…tBox dijitComboBox dijitDateTextBox dijitComboBoxOpenOnClick" role="combobox" widgetid="dijit_form_DateTextBox_34">
<div class="dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer" role="presentation" dojoattachpoint="_buttonNode, _popupStateNode" popupactive="true"></div>
<div class="dijitReset dijitValidationContainer"></div>
<div class="dijitReset dijitInputField dijitInputContainer">
<input id="dijit_form_DateTextBox_34" class="dijitReset dijitInputInner" type="text" aria-haspopup="true" role="textbox" dojoattachpoint="textbox,focusNode" autocomplete="off" aria-valuenow="null" aria-invalid="false" tabindex="0" value="" style="" delocalized="null" aria-disabled="false"></input>
<input type="hidden" value=""></input>
</div>
</div>
</span>
<span dojoattachpoint="rightPicker"></span>
<span style="position: absolute;" dojoattachpoint="calImage"></span>
<input id="outDate_0_0" type="text" isdatefield="true" name="tw#local#quoteComparison#0#country#0#outDate" style="display:none" dojoattachpoint="hiddenInput" delocalized="null"></input>
</div>
</div>
</div>
</td>
<td id="BuyQuantity0_0" class="twTableTD" align="center" onblur="updateAvgPerWeek(0,0)" name="BuyQuantity0"></td>
<td id="TotalCost0_0" class="twTableTD" align="center" name="TotalCost0"></td>
<td id="NumberOfWarehouses0_0" class="twTableTD" align="center" onblur="updateAvgPerWeek(0,0)" td=""></td>
<!--
# of Warehouses
-->
<td id="AveragePerWarehouse0_0" class="twTableTD" align="center" name="AvgPerWhouseWeek0"></td>
<!--
Cost per Warehouse
-->`enter code here`
<td id="ProjectedSellPrice0_0" class="twTableTD" align="center" td=""></td>
<!--
Projected Sell Price
-->
<td id="PercentOfTotal0_0" class="twTableTD" align="center"></td>
<td class="twTableTD" align="center" rowspan="2"></td>
</tr>

The best xpath I am able to come up with is this:
//td[normalize-space()='QA GM 04012014 1424 Item Name']/following-sibling::td[contains(#id, 'shipDate')]//input[contains(#class,'dijitInputInner')]
Let me explain:
This part finds the td element with the text you're looking for, the normalize-space() call is just like text(), but trims any whitespace before/after the text & I've found it to be invaluable since discovering it a short time ago. text() will return whitespace and is often difficult to match
//td[normalize-space()='QA GM 04012014 1424 Item Name']
This next part finds ALL td's after the previous element. From the code snippet provided this will find ALL 13 td's that follow
/following-sibling::td
Narrow down that set of 13 by finding only the td containing the ID you're interested in, this is better than using a hardcoded number like /following-sibling::td[2] to find the second td
/following-sibling::td[contains(#id, 'shipDate')]
Then find the input field that you're interested in, there are number of ways you could do this, choose whichever you prefer
//input[contains(#class,'dijitInputInner')]
//input[contains(#id,'dijit_form_DateTextBox')]
I hope that's clear enough & works well for you, please let me know if not

Related

Not able to check the check box, exception "element not visible"

In an table which can contain more rows, user is searchable using the email id. After searching, selecting the first check box. But selenium is throwing the element not visible exception.
//*[#id='share_user']/tbody/tr1/td1//label
//*[#id='share_user']/tbody/tr1/td1//input
//label[#for='checkbox_416']
last identifier is dynamic. Still getting the element not visible exception.
Table code is mentioned below
<table class="table table-striped table-hover dataTable" id="share_user"
aria-describedby="share_user_info">
<thead>
<tr role="row">
<th class="small-cell sorting" role="columnheader" tabindex="0"
aria-controls="share_user" rowspan="1" colspan="1" style="width: 137px;"
aria-label="Share Profile : activate to sort column ascending">Share Profile </th>
<th class="medium-cell sorting" role="columnheader" tabindex="0"
aria-controls="share_user" rowspan="1" colspan="1" style="width: 523px;"
aria-label="User Details: activate to sort column ascending">User Details</th>
<th class="medium-cell sorting_asc" role="columnheader" tabindex="0"
aria-controls="share_user" rowspan="1" colspan="1" style="width: 366px;"
aria-sort="ascending" aria-label="Access: activate to sort column descending">Access</th>
</tr>
</thead>
<tbody role="alert" aria-live="polite" aria-relevant="all">
<tr class="odd">
<td class="">
<div class="checkbox check-default">
<input name="checkUser" id="checkbox_416" value="416" class="shareCheck"
type="checkbox">
<label for="checkbox_416"></label>
</div>
</td>
<td class=" ">
<img src="" class="img-responsive display-inline share-image">
<div class="display-inline">
<p class="share-name">alexx</p>
<p class="muted">
<i class="fa fa-envelope" hidden="true"></i>
<span>alexxm360#gmail.com</span>
</p>
</div>
</td>
<td style="vertical-align: middle;" class=" sorting_1">
<div class="select2-container medium-cell" id="s2id_rolelink416"
style="float:left;">
<a href="javascript:void(0)" onclick="return false;" class="select2-choice"
tabindex="-1">
<span class="select2-chosen">PROFILE ADMIN</span>
<abbr class="select2-search-choice-close"></abbr>
<span class="select2-arrow">
<b></b>
</span>
</a>
<input class="select2-focusser select2-offscreen" id="s2id_autogen11"
type="text">
<div class="select2-drop select2-display-none select2-with-searchbox">
<div class="select2-search">
<input autocomplete="off" autocorrect="off"
autocapitalize="off" spellcheck="false" class="select2-input"
type="text">
</div>
<ul class="select2-results">
</ul>
</div>
</div>
<select name="profileUsers.roleId" id="rolelink416"
class="medium-cell select2-offscreen" style="float:left;" tabindex="-1">
<option value="6">PROFILE ADMIN</option>
<option value="7">PROFILE AGENT</option>
<option value="8">PROFILE VIEWER</option>
<option value="196">profile role</option>
</select>
</td>
</tr>
</tbody>
</table>
providing the screen shots as well.
Try to use explicit wait with Expected Conditions
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement checkbox = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[#id='share_user']/tbody/tr[1]/td[1]//input")));
checkbox.click();
You can use the following expression, I have verified working fine.
driver.findElement(By.xpath("//*[#id='share_user']/tbody/tr[1]/td[1]/div")).click();
Try this
int ele_size=driver.findElements(By.xpath("locator")).size();
driver.findElements(By.xpath("locator")).get(ele_size-1).click();
We might encounter element not visible exception if element matching the locator existed in the DOM but is not currently visible. So we have to take the size of the element in first statement then in next statement we have to take the first element from the list and click on element.
Used this //*[#id='share_user']/tbody/tr[1]/td[1]/div worked

How can I Selecting Kendo Drop Down using xpath

I have the following HTML:
<table class="w98">
<tbody>
<tr>
<tr>
<tr>
<td class="p-controlSetLabel">
<td class="editor-field">
**<span class="k-widget k-dropdown k-header" style="width: 165px;" title="" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="VatRateId_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="304dd433-4a68-458b-a6d6-03b72335f1cb">**
<span class="k-dropdown-wrap k-state-default" unselectable="on">
<span class="k-input" unselectable="on">Standard - Standard</span>
<span class="k-select" unselectable="on">
<span class="k-icon k-i-arrow-s" unselectable="on">select</span>
</span>
</span>
<input id="VatRateId" class="k-valid" type="text" value="d20b" style="width: 165px; display: none;" name="VatRateId" data-val-required="Please select a VAT Rate." data-val="true" data-role="dropdownlist">
The input id="VatRateId" is hidden, so I can't access it.
My current solution is the following:
var allDropDownFields = FindElements(By.XPath(".//*[#class='k-dropdown-wrap k-state-default']") -- This will return a list of all drop down fields
Then I loop each one of them to find the correct drop down field I want.
Is there a better way of finding the element without getting a list, I tried the following:
FindElement(By.XPath(".//*[#class='k-dropdown-wrap k-state-default'and #aria-owns = 'VatRateId_listbox']")
and the above code is not work.
HTML code is as below:-
<span class="k-widget k-dropdown k-header" style="width: 165px;" title="" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="VatRateId_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="304dd433-4a68-458b-a6d6-03b72335f1cb">* <span class="k-dropdown-wrap k-state-default" unselectable="on"> <span class="k-input" unselectable="on">Standard - Standard</span>
Any better suggestion?

Is it possible for selenium to find a label element by its "for" attribute using xpath?

Is it possible for selenium to find a label element by its "for" attribute using xpath?
I'm testing a site that has 7 yes or no questions in row. The way the CSS is done, you click on the label instead of the input radio button. Normally I'd just find the element by text content, but there is a yes and no for each question.
I'm thinking that a work-around would be to do a javascript click on the input button to get around the "element is not visible" error that I get when trying to .click() the input directly, but I wanted to see if there was a better way to locate the label which is what users would actually be clicking.
*Edit for all of your who can't remember what a label element looks like. How would you select the middle one from this group?
<label for="superLongSetOfRandomCharacters123" class="common-to-all-buttons"> No </label>
<label for="superLongSetOfRandomCharacters345" class="common-to-all-buttons"> No </label>
<label for="superLongSetOfRandomCharacters456" class="common-to-all-buttons"> No </label>
More specifically, this is how they sit in the DOM
<ul class="list-view list-view-dividers">
<li class="list-view-item">
<div class="content">
<div id="variableValue1" class="multipleChoice">
<div class="form-row">
<label>Question 1</label>
<div class="form-row">
<table class="choices" id="randomlyGenerated-1">
<tbody>
<tr>
<td>
<div class="ui-radio"><label for="randomlyGenerated1" class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off"> Yes</label><input id="randomlyGenerated1" type="radio" name="randomlyGenerated1" value="Yes"></div>
</td>
<td>
<div class="ui-radio"><label for="randomlyGenerated2" class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off"> No</label><input id="randomlyGenerated2" type="radio" name="randomlyGenerated2" value="No"></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="randomlyGenerated1-Error" class="component-error"></div>
</div>
</div>
</li>
<li class="list-view-item">
<div class="content">
<div id="variableValue2" class="multipleChoice">
<div class="form-row">
<label>Question 2</label>
<div class="form-row">
<table class="choices" id="randomlyGenerated-2">
<tbody>
<tr>
<td>
<div class="ui-radio"><label for="randomlyGenerated21" class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off"> Yes</label><input id="randomlyGenerated21" type="radio" name="randomlyGenerated21" value="Yes"></div>
</td>
<td>
<div class="ui-radio"><label for="randomlyGenerated22" class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off"> No</label><input id="randomlyGenerated22" type="radio" name="randomlyGenerated22" value="No"></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="randomlyGenerated2-Error" class="component-error"></div>
</div>
</div>
</li>
</ul>
It works for selecting all labels with target 'for':
label[#for='superLongSetOfRandomCharacters123']
or you can leave #for='' blank for selecting all labels with any values (i.e. label[#for])
I guess, the XPath-Option you are looking for would be "#". so in your case something like [...]/label/#for would return you that for-value, which you could then use to check where you are ;)
Cheers
D
Use find_element_by_xpath
label = self.browser.find_element_by_xpath('//label[#for="id_field"]')

Form group static in bootstrap 3

AM using bootstrap 3 for my python web application. I want to use the application in mobile devices also. but the input form fields are become responsive to the width of the device. I want in input field width to be static as in browser . please advice how to achieve this?
below is the html which am using
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<div class="col-md-2 pull-left">
Add Timesheet Details
</div>
<div class="col-md-8 text-center">
<label class="control-label" for="timesheet_no">Time Sheet Number:01</label>
</div>
</div>
</div>
<div class="panel-body">
<form id="add_detail" class="form-horizontal" action="" method="post" name="page">
<div style="display:none;"><input id="csrf_token" name="csrf_token" type="hidden" value="1434973923##5ac019cd8821a1dfda978dde3710893c8b0ced33"></div>
<div class="form-group">
<div class="repeat" id="dimdetail-fieldset">
<div class="col-md-12">
<div class ="table-responsive">
<table id="table_id" class="wrapper table table-bordered">
<thead>
<tr>
<th class="col-md-2"><button type="button" class="add btn btn-primary pull-left" id="add_time"><i class="glyphicon glyphicon-plus"></i>&nbsp Time</button></th>
</tr>
</thead>
<tbody class="container">
<tr class="success">
<th class="col-md-2">Project</th>
<th class="col-md-2">Total Hours</th>
<th class="col-md-2">TPI Inspector Name</th>
<th class="col-md-2">Inspection Type</th>
<th class="col-md-2">Remarks</th>
<th></th>
</tr>
<tr >
<td class="form-group col-md-2">
<select class="form-control" id="timesheet_time_details-0-project_id" name="timesheet_time_details-0-project_id" style="width:100%"><option value="">-- please choose --</option>
<option value="12997">12997</option></select>
</td>
<td class="form-group col-md-2">
<input class="form-control" id="timesheet_time_details-0-total_hours" name="timesheet_time_details-0-total_hours" type="text" value="10.0">
</td>
<td class="form-group col-md-2">
<input class="form-control" id="timesheet_time_details-0-tpi_inspector_name" name="timesheet_time_details-0-tpi_inspector_name" type="text" value="Ram">
</td>
<td class="form-group col-md-2">
<select class="form-control" id="timesheet_time_details-0-testmethod" name="timesheet_time_details-0-testmethod" style="width:100%"><option value="__None">-- please choose --</option><option selected value="1">UltraSonic Inspection</option></select>
</td>
<td class="form-group col-md-2">
<textarea class="form-control" id="timesheet_time_details-0-remarks" name="timesheet_time_details-0-remarks" rows="3">ok</textarea>
</td>
<td class="col-md-1">
<button class="remove btn btn-danger" type="button" id=""><i class='glyphicon glyphicon-trash'></i> Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<div class="row">
<div class="col-md-10 pull-left">
<button class="btn btn-primary" type="submit" value="Save" name="Save"><i class="glyphicon glyphicon-save"></i>&nbsp Save</button>
<button class="btn btn-success" type="submit" value="Submit for Approval" name="Save"><i class="glyphicon glyphicon-ok-circle"></i>&nbsp Submit for Approval</button>
<button id="delete" class="btn btn-danger" type="submit" value="Delete" name="Save"><i class="glyphicon glyphicon-trash"></i>&nbsp Delete</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
Add the below css
.form-control {width:150px} /*the width you want*/
make sure it renders after your bootstrap css. You are however getting rid of the responsiveness of the row that contains the inputs.
here is a bootply example

Selenium locate <textbox> nested in <table td>

i want to select the specific textbox from a form based on its id attribute using selenium.
I tried this below code but its showing "unable to locate id..." error.
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']"));`
and also i tried like WebElement textbox = driver.findElement(By.id("leadCaptureList_leadCapture_firstName")); but still no luck.
Is there anything in selenium to select nested textbox element ?
http://my.jetscreenshot.com/demo/20140304-c1dk-105kb.jpg (Press CTRL + to zoom image)
Here(in image) is the html structure of my page.
In this image i have highlighted the textbox for which i am trying to target.
html code as suggested in comment below
<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">My Account | <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">LeadOutcome</span> <span class="breadcrumb-link">Leads</span> <span class="breadcrumb-link">Manage Leads</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> </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>
<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> <img src="images/btn_find_IR.png" border="0"></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>
<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"><img src="images/btn_m_show_advanced.png" border="0">
</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">
<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>
Finding a textbox which has an id attribute should practically not fail. Selenium WILL find it if it's there. In case if the element is not present / visible in the DOM when the findElement command gets executed then Selenium will throw an exception.
You can try WebDriver explict wait like this and see if it works:
WebElement textBox = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.visibilityOfElementLocated(By.id("leadCaptureList_leadCapture_firstName")));