Unable to print a perticular name in selenium webdriver using java - java

My Java
package com.ej.zob.modules;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
public class Manage_Branch {
public void Execute(String IFSC)
{
LaunchApplication.driver.findElement(By.linkText("MANAGE")).click();
LaunchApplication.driver.findElement(By.linkText("BRANCH")).click();
LaunchApplication.driver.findElement(By.xpath("//tbody/tr/td/div[text()='"+IFSC+"']"));
WebElement col = LaunchApplication.driver.findElement(By.xpath("//table/tbody/tr/td[count(//table/thead/tr/th[.='BRANCH NAME']/preceding-sibling::th)+4]"));
if(IFSC.equalsIgnoreCase(IFSC))
{
System.out.println(col.getText());
}
}
}
My HTML
<table id="flex1" cellspacing="0" cellpadding="0" border="0">
<thead>
<tr class="hDiv">
<th width="6%">
<div class="text-left field-sorting asc" rel="IFSC_CODE"> IFSC CODE </div>
</th>
<th width="6%">
<div class="text-left field-sorting " rel="BRANCH_NAME"> BRANCH NAME </div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="sorted" width="6%">
<div class="text-left">SACS011151</div>
</td>
<td width="6%">
<div class="text-left">check</div>
</td>
</tr>
<tr class="erow">
<td class="sorted" width="6%">
<div class="text-left">SACS011152</div>
</td>
<td width="6%">
<div class="text-left">Motiram</div>
</td>
</tr>
<tr class="erow">
<td class="sorted" width="6%">
<div class="text-left">SACS011158</div>
</td>
<td width="6%">
<div class="text-left">TESTNAME</div>
</td>
</tr>
</tbody>
</table>
I want to print value from column name "BRANCH NAME" say "check" but when user passes value of IFSC CODE say "SACS011151" then the value in front of that particular IFSC CODE should be printed.But in my case it is printing the value from 8th row only whatever the IFSC code you pass it is only taking "TESTNAME". For help you can see the above image for better understanding.I don't know why it is happening. Hope you understand Any help?

Try this:
WebElement col = LaunchApplication.driver.findElement(By.xpath("//thead//div[text()='+"IFSC"+']//../following-sibling::td/div"));

WebElement col = LaunchApplication.driver.findElement(By.tagName('tbody')).findElement(By.tagName('tr')).findElements(By.tagName('td'))[1]

Once try this:
WebElement col = LaunchApplication.driver.findElement(By.xpath("//tbody/tr[1]/td[1]/div[text()='SACS011151']"));
if(col.equals("SACS011151")){
WebElement branchNameEle = LaunchApplication.driver.findElement(By.xpath("//tbody/tr[1]/td[4]"));
System.out.println("BranchName: "+branchNameEle.getText());
}

Related

Thymeleaf. How to hide element based on boolean parametr?

I have a table of reviews
<table class="table">
<tbody>
<tr th:each="review : ${reviewsForMovie}">
<td th:utext="${review.text}"></td>
</tr>
</tbody>
</table>
But I dont want to show review if review.isApproved == false
How do i do that?
<table class="table">
<tbody>
<tr th:each="review : ${reviewsForMovie}">
<td th:hidden="${!review.isApproved}" th:utext="${review.text}"></td>
</tr>
</tbody>
</table>

Using java.net.URLConnection to fetch data in html fetching only html code and not the actual data

Using java.net.URLConnection to fetch data from html is not fetching the actual data but only the html code.
Since the html is generating data dynamically the core html code doesn't have the data that is being displayed on the html.
Is there any other means of fetching the data being displayed on the html page?
My code goes like this:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class Example {
public static void main(String[] args) throws IOException {
System.setProperty("java.net.useSystemProxies", "true");
// Make a URL to the web page
URL url = new URL("https://rci-dtengine.rnd.ki.sw.ericsson.se/root//proj/cpptemp/jcat-cpp/DI/megatron/DT/INT_PA284/20170331_152720/20170331_152723/index.html");
// Get the input stream through URL Connection
URLConnection con = url.openConnection();
InputStream is =con.getInputStream();
// Once you have the Input Stream, it's just plain old Java IO stuff.
// For this case, since you are interested in getting plain-text web page
// I'll use a reader and output the text content to System.out.
// For binary content, it's better to directly read the bytes from stream and write
// to the target file.
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = null;
// read each line and write to System.out
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
}
Output:
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="img/jcat_m3.png"/>
<title>JCAT Test Report</title>
<link rel="stylesheet" type="text/css" href="css/jquery.fancybox.css" />
<link rel="stylesheet" type="text/css" href="css/top.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css" />
<link rel="stylesheet" type="text/css" href="css/testsuite.css" />
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/jquery.fancybox.pack.js"></script>
<script src="js/jquery.storage.js"></script>
<script src="js/stupidtable.min.js"></script>
<script src="js/common.js"></script>
<script src="js/top.js"></script>
<script src="js/testsuite.js"></script>
<script>
window.onerror = function () {
alert("Failed to load data files as the format is corrupt!");
};
function receiveMessage(event) {
if (event.data !== "reload from settings") {
return;
}
window.location.reload();
}
window.addEventListener("message", receiveMessage, false);
</script>
<script src="json/suite.data.js"></script>
<script src="json/top.data.js"></script>
<script src="json/bulletin.message.data.js"></script>
</head>
<body>
<div class='top'></div>
<div id="bulletin">
<div id="bulletinBar">
<img id="bulletinSwitch"></img>
<span id="bulletinHint" style="display:none">hide bulletin</span>
</div>
<div id="bulletinFrame" class="ui-widget-content">
<div id="bulletinContent"></div>
</div>
</div>
<div id="autoRefresh">
<span id="refreshCountDown" style="display:none"></span>
<input id='autoRefreshBtn' type='button' value='enable auto refresh'></input>
</div>
<div id="content">
<div id="sumBlock">
<h3>Report Summary</h3>
<table id="suiteInfo" summary="Suite summary information">
<tbody>
<tr>
<td width="130px">Suite name:</td>
<td id="suiteName"></td>
</tr>
<tr>
<td>Run by:</td>
<td id="runBy"></td>
</tr>
<tr>
<td>Time started:</td>
<td id="startTime" class="timestamp"></td>
</tr>
<tr>
<td>Time finished:</td>
<td id="endTime" class="timestamp"></td>
</tr>
<tr>
<td>Duration:</td>
<td id="duration"></td>
</tr>
</tbody>
</table>
</div>
<div id="staBlock">
<h3>Statistics</h3>
<table id="statistics" summary="Suite statistic">
<tbody>
<tr>
<td width="100px">Passed TCs:</td>
<td id="tcPassed" width="50px"></td>
<td width="120px">Passed configs:</td>
<td id="configTcPassed" width="50px"></td>
</tr>
<tr>
<td>Failed TCs:</td>
<td id="tcFailed"></td>
<td >Failed configs:</td>
<td id="configTcFailed"></td>
</tr>
<tr>
<td>Error TCs:</td>
<td id="tcError"></td>
<td>Error configs:</td>
<td id="configTcError"></td>
</tr>
<tr>
<td>Skipped TCs:</td>
<td id="tcSkipped"></td>
<td>Skipped configs:</td>
<td id="configTcSkipped"></td>
</tr>
<tr>
<td>Excluded TCs:</td>
<td id="tcExcluded"></td>
<td>Executed configs:</td>
<td id="configTcRun"></td>
</tr>
<tr>
<td>Inconclusive TCs:</td>
<td id="tcInconclusive"></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Executed TCs:</td>
<td id="tcRun"></td>
<td></td>
<td></td>
</tr>
<tr>
<td>UnExecuted TCs:</td>
<td id="tcNotRun"></td>
<td>TCs & configs:</td>
<td id="tcTotalRun"></td>
</tr>
</tbody>
</table>
</div>
<div id="testCases">
<input placeholder="Search..." type="text" id="filterText" maxlength="200" style="margin-left:5px;"/>
<div id='viewSwitch' style='display:none'>
| <span id="nestedFunc" style='display:none'> Show Nested Suites<input id='nestedSwitch' onchange="switchSuiteTable(this)" type="checkbox" value="Nested"></span>
<span id="groupedFunc" style='display:none'> Show Grouped Suite<input id='groupedSwitch' onchange="switchSuiteTable(this)" type="checkbox" value="Grouped"></span>
Auto-unfold Errors<input id='autoUnfold' onchange="setAutoUnfold()" type="checkbox" value="autoUnfold" checked="checked">
<input id="unfoldFunc" type="button" value="Unfold" onclick="$('tr.folded').click()">
<input id="foldFunc" type="button" value="Fold" onclick="$('tr.unfolded').click()">
</div>
| <span id="filter_icondown" style="color: #99cc00">&#9658</span> <span id="filter_iconright" style="color: #99cc00; display: none">&#9660</span>
<a id="filterHide" href="javascript:hideUnhideTable('filter')">Filters</a>
<div id="jcat_label">
| <span id="label_text">Labels:</span>
<select id="label_select">
</select>
</div>
<table id="filter" style="display: none;">
<tr>
<td width="120px">Passed TCs/configs:</td>
<td width="50px"><a id="label_passed" href="javascript:hideUnhideRows('passed')">Hide</a></td>
<td width="160px">Skipped TCs/configs:</td>
<td width="50px"><a id="label_skipped" href="javascript:hideUnhideRows('skipped')">Hide</a></td>
<td width="160px">All testcases:</td>
<td width="50px"><a id="label_testcases" href="javascript:hideUnhideRows('testcases')">Hide</a></td>
</tr>
<tr>
<td>Failed TCs/configs:</td>
<td><a id="label_failed" href="javascript:hideUnhideRows('failed')">Hide</a></td>
<td>Excluded TCs/configs:</td>
<td><a id="label_excluded" href="javascript:hideUnhideRows('excluded')">Hide</a></td>
<td>All configuration methods:</td>
<td><a id="label_cfgs" href="javascript:hideUnhideRows('cfgs')">Hide</a></td>
</tr>
<tr>
<td>Error TCs/configs:</td>
<td><a id="label_error" href="javascript:hideUnhideRows('error')">Hide</a></td>
<td>Inconclusive TCs/configs:</td>
<td><a id="label_inconc" href="javascript:hideUnhideRows('inconc')">Hide</a></td>
<td>All reruned testcases:</td>
<td><a id="label_rerun" href="javascript:hideUnhideRows('rerun')">Show</a></td>
</tr>
</table>
<table id="suiteTable" class='suite'>
<thead>
<tr>
<th data-sort="int" id="tcIndex" style="display:none">Index</th>
<th data-sort="string">ID</th>
<th data-sort="string">Name</th>
<th data-sort="string">Type</th>
<th data-sort="string">Heading</th>
<th data-sort="int">State</th>
<th data-sort="string">Additional Result Info</th>
<th data-sort="string" style="display:none;">Start Time</th>
<th data-sort="string" style="display:none;">End Time</th>
<th data-sort="string">Duration</th>
<th data-sort="string">Fetched Logs</th>
<th data-sort="string">Labels</th>
</tr>
</thead>
<tbody></tbody>
</table>
<table id="nestedTable" class='suite Nested' style="display:none">
<thead>
<tr>
<th id="tcIndex" style="display:none">Index</th>
<th>ID</th>
<th>Name</th>
<th>Type</th>
<th>Heading</th>
<th>State</th>
<th>Additional Result Info</th>
<th style="display:none;">Start Time</th>
<th style="display:none;">End Time</th>
<th>Duration</th>
<th>Fetched Logs</th>
<th>Labels</th>
</tr>
</thead>
<tbody></tbody>
</table>
<table id="groupedTable" class='suite Grouped' style="display:none">
<thead>
<tr>
<th id="tcIndex" style="display:none">Index</th>
<th>ID</th>
<th>Name</th>
<th>Type</th>
<th>Heading</th>
<th>State</th>
<th>Additional Result Info</th>
<th style="display:none;">Start Time</th>
<th style="display:none;">End Time</th>
<th>Duration</th>
<th>Fetched Logs</th>
<th>Labels</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</body>
</html>
The only way to know the underlying API is if the site itself makes that information public.
As for loading the page, you’ll need a container capable of loading the page and executing its JavaScript; the WebView class of JavaFX is one such container. Every WebView has an associated WebEngine which provides the loaded page as an XML Document (even if the original content was not XHTML); you can use XPath on that Document to extract the text of the relevant <td> elements.

I would like to count data from HTML table availble on multiple page for specific text webdriver java

I am trying Count total number of rows.
I need to count the different type of status available (Inactive,Active,Expired & Exhausted)
Current code is only fetching:
Count of rows
Text of Status and Name but I need only count written next to Status type.
It only fetch data from first page. Pages are populated based on the number transactions.
following is the code written:
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class counting {
public static void main(String[] args) {
String Status="Inactive";
//String NextPage="Inactive";
WebDriver driver= new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.navigate().to("http://Testsite/web");
driver.findElement(By.id("UserEntry")).sendKeys("00");
//Type Last Name
driver.findElement(By.id("Password")).sendKeys("Test");
// Click on Submit
driver.findElement(By.id("LoginButton")).click();
driver.findElement(By.linkText("Accounts"));
driver.findElement(By.linkText("Accounts")).click();
driver.findElement(By.xpath("html/body/form/div[3]/div/div[2]/table /tbody/tr/td[1]/div/ul/li[2]/a")).click();
List<WebElement> Account = driver.findElements(By.xpath("//table[#id='MainPlaceholder_AccountList']/tbody/tr/td[1]"));
List<WebElement> AccountStatus = driver.findElements(By.xpath("//table[#id='MainPlaceholder_AccountList']/tbody/tr/td[5]"));
System.out.println("Total Account- "+Account.size());
System.out.println("Total Status- "+AccountStatus.size());
Your code isn't fully formatted properly. I have used Appium (so it is selenium backend) for mobile tests and I am going to assume you could try to create a table that reaches to a certain point, and then rows that are composed of a certain className (or in your case I suppose a id value).
Ex:
table = (MobileElement) driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[2]/UIATableView[1]"));
rows = table.findElementsByClassName("UIATableCell");
The driver being a IOSDriver. Now this is how I locate certain elements for the iOS tests. But again, I am going to assume the logic is the same. Once you locate what you need, just populate your array with the objects.
Once you populate your array you could probably parse it to fit your needs.
for(int i=0;i<AccountStatus.size();i++){
if(AccountStatus.get(i).getText().equals(Status))
System.out.println(Account.get(i).getText()+" --- "+AccountStatus.get(i).getText());
}
}
}
HTML COde:
<table id="MainPlaceholder_AccountList" cellspacing="1" cellpadding="10" border="1" style="background-color:#888888;width:100%;font-size: 75%; padding: 5px;" rules="all">
<tbody>
<tr align="center" style="color:White;background-color:#232356;">
<th scope="col">Account Name</th>
<th scope="col">Number</th>
<th scope="col">Program</th>
<th scope="col">Site</th>
<th scope="col">Status</th>
<th scope="col">Edit</th>
<th scope="col">Delete</th>
</tr>
<tr style="background-color:White;">
<td class="capText" style="width:220px;">Last, First</td>
<td class="padIt" align="center" style="width:60px;">4563201</td>
<td class="capText" style="width:150px;"> </td>
<td class="padIt" style="width:115px;">local</td>
<td class="padIt" style="width:90px;">Active</td>
<td style="width:75px;">
<td style="width:75px;">
<td style="width:75px;">
<input id="MainPlaceholder_AccountList_EditAccount_0" type="submit" style="width:75px;" eid="550" value="Edit..." name="ctl00$MainPlaceholder$AccountList$ctl02$EditAccount">
</td>
<td style="width:75px;">
<input id="MainPlaceholder_AccountList_DeleteAccount_0" type="submit" style="width:75px;" eid="550" onclick="return confirm('Are you sure you want to delete the selected account?');" value="Delete" name="ctl00$MainPlaceholder$AccountList$ctl02$DeleteAccount">
</td>
td style="text-align: center">
<span id="MainPlaceholder_PageLabel" style="margin-right: 5px;">Page:</span>
<input id="MainPlaceholder_CurrentPage" type="text" style="width:40px;text-align: right" onclick="javascript:this.value="";" title="Type in a page number, then press the Enter key to go directly to that page." maxlength="5" value="1" name="ctl00$MainPlaceholder$CurrentPage">
<span id="MainPlaceholder_OfLabel" style="margin-left: 5px; margin-right: 5px;">of</span>
<span id="MainPlaceholder_TotalPages" style="margin-right: 5px;">21</span>
<input id="MainPlaceholder_LastButton" type="submit" style="height:24px;width:90px;" value="▼▼ Last" name="ctl00$MainPlaceholder$LastButton">
<input id="MainPlaceholder_NextButton" type="submit" style="height:24px;width:90px;" value="▼ Next" name="ctl00$MainPlaceholder$NextButton">
<input id="MainPlaceholder_PreviousButton" type="submit" style="height:24px;width:90px;" value="Previous ▲" name="ctl00$MainPlaceholder$PreviousButton">
<input id="MainPlaceholder_FirstButton" type="submit" style="height:24px;width:90px;" value="First ▲▲" name="ctl00$MainPlaceholder$FirstButton">
</td>

Don't see any input command in selenium for Input Tag-based DevExpress Dropdown Editor

I have an element that looks like combo box ( DevEx control ). Its Tag is input and not Select. Hence Select command does not work. I can locate that element and when send a click command, it opens the list. However, I am not able to select any Value from it.
Code snippet using firebug is as follows:
input id="ctl00_MainContent_tbc_UserRights_tbpnl_UserInfo_ddl_Company_I" class="dxeEditArea dxeEditAreaSys" type="text" style="cursor:default;" onchange="aspxETextChanged('ctl00_MainContent_tbc_UserRights_tbpnl_UserInfo_ddl_Company')" readonly="readonly" name="ctl00$MainContent$tbc_UserRights$tbpnl_UserInfo$ddl_Company" autocomplete="off" tabindex="14" onfocus="aspxEGotFocus('ctl00_MainContent_tbc_UserRights_tbpnl_UserInfo_ddl_Company')" onblur="aspxELostFocus('ctl00_MainContent_tbc_UserRights_tbpnl_UserInfo_ddl_Company'
Selenium Code is as Follows
WebElement companydropdown = driver.findElement(By.id("ctl00_MainContent_tbc_UserRights_tbpnl_UserInfo_ddl_Company_I")); Select Clickthis1 = new Select (companydropdown); clickThis.selectByVisibleText("Multi National Retail Group");
error is as follows
Exception in thread "main" org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "input" Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35' System info: host: 'ct-113', ip: '172.24.1.248', os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.8.0_45' Driver info: driver.version: unknown at org.openqa.selenium.support.ui.Select.(Select.java:46) at MyPackage.MyClass.main(MyClass``.java:113)
Your drop down list is being simulated by JavaScript. It's probably a DIV (or maybe a SELECT or TABLE) after clicking the input, so you will need to locate that new element after clicking the input.
There's no built in command. You may need to FindElement(By.CssPath("table[id*=ddl_Company] td:contains(Default Company)")) and click it
Please see below code snippet, I have written in c# but you can take this reference for any language.
Basic idea is to design logic to select elements from dropdown by using FindElement and FindElements.
Extension Method of IWebDriver
public static class SeleniumExtension
{
public static void SelectDropDownByText(this IWebDriver driver, string clickId, string tableId, string visibleText)
{
//Click on dropdown element to see dropdown options
driver.FindElement(By.Id(clickId)).Click();
//Get all rows from the table(dropdown options table) by tableId
var trElements = driver.FindElement(By.Id(tableId)).FindElements(By.CssSelector("tr"));1
//Go to row by row
foreach(var trElement in trElements)
{
//Select celll(td) of the row
var tdElement = trElement.FindElement(By.CssSelector("td"));
//Scoll to that td so we can select the td
Actions actions = new Actions(driver);
actions.MoveToElement(tdElement);
actions.Perform();
//CHeck td text if td text is equal to given text then click that td
if (tdElement.Text.Trim() == visibleText.Trim())
{
//Select td/dropdown option
tdElement.Click();
break;
}
}
}
}
Limitations:-
The dropdown items should not have duplicate text elements
Just found one way to select it by visible text, not by Id or Value
Code example :
Web page source code
<td width="55%" valign="top" align="left">
<table class="dxeButtonEdit inputBox" cellspacing="1" cellpadding="0" id="EnterOrderModel.reportstoprofs" style="width:150px;">
<tbody>
<tr>
<td style="display:none;"><input id="EnterOrderModel.reportstoprofs_VI" name="EnterOrderModel.reportstoprofs_VI" type="hidden" value="AAAA"></td>
<td class="dxic" onmousedown="return aspxDDDropDown('EnterOrderModel.reportstoprofs', event)" style="width:100%;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;"><input class="dxeEditArea dxeEditAreaSys" id="EnterOrderModel.reportstoprofs_I" name="EnterOrderModel.reportstoprofs" onfocus="aspxEGotFocus('EnterOrderModel.reportstoprofs')" onblur="aspxELostFocus('EnterOrderModel.reportstoprofs')" onchange="aspxETextChanged('EnterOrderModel.reportstoprofs')" onkeydown="aspxEKeyDown('EnterOrderModel.reportstoprofs', event)" value="Parmnad(AAAA)" type="text" style="height:15px;" autocomplete="off"></td>
<td id="EnterOrderModel.reportstoprofs_B-1" class="dxeButtonEditButton" onmousedown="return aspxDDDropDown('EnterOrderModel.reportstoprofs', event)" style="-khtml-user-select:none;">
<table class="dxbebt" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border-collapse:separate;">
<tbody>
<tr>
<td class="dx"><img id="EnterOrderModel.reportstoprofs_B-1Img" class="dxEditors_edtDropDown" src="/DXR.axd?r=1_5-7rgYm" alt="v"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<input type="hidden" id="EnterOrderModel.reportstoprofs_DDDWS" name="EnterOrderModel.reportstoprofs_DDDWS" value="0:0:-1:-10000:-10000:0:-10000:-10000:1">
<div id="EnterOrderModel.reportstoprofs_DDD_PW-1" style="position:absolute;left:0px;top:0px;z-index:10000;visibility:hidden;display:none;">
<table id="EnterOrderModel.reportstoprofs_DDD_PWST-1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border-collapse:separate;position:relative;">
<tbody>
<tr>
<td onmousedown="aspxPWMDown(event,'EnterOrderModel.reportstoprofs_DDD',-1,false)" style="width:200px;cursor:default;">
<table id="EnterOrderModel.reportstoprofs_DDD_CLW-1" cellspacing="0" cellpadding="0" style="width:200px;border-collapse:collapse;border-collapse:separate;">
<tbody>
<tr>
<td id="EnterOrderModel.reportstoprofs_DDD_PWC-1" style="height:100%;">
<div id="EnterOrderModel.reportstoprofs_DDD_CSD-1">
<input type="hidden" id="EnterOrderModel.reportstoprofs_DDD_LDeletedItems" name="EnterOrderModel.reportstoprofs_DDD_LDeletedItems" value=""><input type="hidden" id="EnterOrderModel.reportstoprofs_DDD_LInsertedItems" name="EnterOrderModel.reportstoprofs_DDD_LInsertedItems" value=""><input type="hidden" id="EnterOrderModel.reportstoprofs_DDD_LCustomCallback" name="EnterOrderModel.reportstoprofs_DDD_LCustomCallback" value="">
<table class="dxeListBox" cellspacing="0" cellpadding="0" id="EnterOrderModel.reportstoprofs_DDD_L" style="border-collapse:collapse;border-collapse:separate;">
<tbody>
<tr>
<td valign="top">
<div id="EnterOrderModel.reportstoprofs_DDD_L_D" class="dxlbd" style="width:100%;overflow-x:hidden;overflow-y:auto;">
<input id="EnterOrderModel.reportstoprofs_DDD_L_VI" type="hidden" name="EnterOrderModel.reportstoprofs$DDD$L" value="AAAA">
<table cellspacing="0" cellpadding="0" style="border-collapse:collapse;border-collapse:separate;visibility:hidden!important;display:none!important;">
<tbody>
<tr id="EnterOrderModel.reportstoprofs_DDD_L_LBI-1" class="dxeListBoxItemRow">
<td id="EnterOrderModel.reportstoprofs_DDD_L_LBI-1T0" class="dxeListBoxItem"> </td>
</tr>
</tbody>
</table>
<div id="EnterOrderModel.reportstoprofs_DDD_L_TS" style="display: none;">
</div>
<table id="EnterOrderModel.reportstoprofs_DDD_L_LBT" cellspacing="0" cellpadding="0" style="width:100%;border-collapse:collapse;border-collapse:separate;">
<tbody>
<tr class="dxeListBoxItemRow">
<td class="dxeListBoxItem" id="EnterOrderModel.reportstoprofs_DDD_L_LBI0T0">Select One</td>
</tr>
<tr class="dxeListBoxItemRow">
<td class="dxeListBoxItem" id="EnterOrderModel.reportstoprofs_DDD_L_LBI1T0">Macccc Dongle</td>
</tr>
<tr class="dxeListBoxItemRow">
<td class="dxeListBoxItem" id="EnterOrderModel.reportstoprofs_DDD_L_LBI2T0">Rock Start</td>
</tr>
<tr class="dxeListBoxItemRow">
<td class="dxeListBoxItem" id="EnterOrderModel.reportstoprofs_DDD_L_LBI3T0">Alliau babbaa</td>
</tr>
<tr class="dxeListBoxItemRow">
<td class="dxeListBoxItem" id="EnterOrderModel.reportstoprofs_DDD_L_LBI4T0">Mong star audomma</td>
</tr>
</tbody>
</table>
<div id="EnterOrderModel.reportstoprofs_DDD_L_BS" style="display: none;">
</div>
</div>
</td>
</tr>
</tbody>
</table>
<script id="dxss_1356993039" type="text/javascript">
<!--
aspxAddDisabledItems('EnterOrderModel.reportstoprofs_DDD_L',[[['dxeDisabled'],[''],['']]]);
var dxo = new ASPxClientListBox('EnterOrderModel.reportstoprofs_DDD_L');
window['EnterOrderModel.reportstoprofs_DDD_L'] = dxo;
dxo.uniqueID = 'EnterOrderModel.reportstoprofs$DDD$L';
dxo.SelectedIndexChanged.AddHandler(function (s, e) { aspxCBLBSelectedIndexChanged('EnterOrderModel.reportstoprofs', e); });
dxo.ItemClick.AddHandler(function (s, e) { aspxCBLBItemMouseUp('EnterOrderModel.reportstoprofs', e); });
dxo.RequireStyleDecoration();
dxo.styleDecoration.AddStyle('F','dxeFocused','');
dxo.savedSelectedIndex = 9;
dxo.itemsValue=['','SFIRTH','TANDE142','BBECK12','KBELLEGH','NBISSON','EBOLDUC','GBORSCHK','GBRISCOE','AAAA','PCAMERON','DCANTAGA','RCARROL2','SCAUVEL','GCAVE1','KCHRIST2','DCOLAPRE','HCUSHMAN','TDENNING','RDERHODG','ADUCHARM','REATON','TERB','MFARLEY4','EFERRELL','DFORTUNA','CFRADET','GGIOVINA','BGOLDBER','BGOODMA1','RGRAMADA','JGUBERNE','JHARTFO2','MHERNIAK','MHORNE3','MHUGGIN1','CHUNT21','JINTRAVA','PJANSEN1','RKANTAUT','DKELLETT','WKIRK1','LKOZMA','VKUSUMAK','RLAURILA','JLEACH1','KLEBLANC','FLEE2','BLESSARD','JMCCAMON','AMCCORM2','TNISSEN','JOLOMAN','EPAHAPI1','APETRIE1','ZRACZ','MRONAN','WROWE2','PROY','TSAVONI','JSNYDER5','LSTIERS','KSTRONG1','GTAIARIO','JTJONG','DTOTTEN','MTRENK1','CTURGEON','JVELLING','PWALWORT','WWELACKY','EWEST2','BWHITE7','SWHITEHE','BWILLI15','DWILLIA3','GWOOD5','KWOODBRI','MYETHON'];
dxo.isSyncEnabled = false;
dxo.isComboBoxList = true;
dxo.hasSampleItem = true;
dxo.isCallbackMode = true;
dxo.callbackPageSize = 100;
dxo.hoverClasses=['dxeListBoxItemHover'];
dxo.selectedClasses=['dxeListBoxItemSelected'];
dxo.disabledClasses=['dxeDisabled'];
dxo.InlineInitialize();
//-->
</script>
</div>
</td>
</tr>
</tbody>
</table>
</td>
<td style="background:url('/DXR.axd?r=1_25-7rgYm') no-repeat left top;"></td>
</tr>
<tr>
<td style="background:url('/DXR.axd?r=1_24-7rgYm') no-repeat left top;"></td>
<td style="background:url('/DXR.axd?r=1_26-7rgYm') no-repeat left top;">
<div style="height:5px;width:5px;">
</div>
</td>
</tr>
</tbody>
</table>
</div>
<script id="dxss_452203440" type="text/javascript">
<!--
var dxo = new ASPxClientPopupControl('EnterOrderModel.reportstoprofs_DDD');
window['EnterOrderModel.reportstoprofs_DDD'] = dxo;
dxo.uniqueID = 'EnterOrderModel.reportstoprofs$DDD';
dxo.Shown.AddHandler(function (s, e) { aspxDDBPCShown('EnterOrderModel.reportstoprofs', e); });
dxo.adjustInnerControlsSizeOnShow=false;
dxo.closeAction='CloseButton';
dxo.popupHorizontalAlign='LeftSides';
dxo.popupVerticalAlign='Below';
dxo.width=0;
dxo.height=0;
dxo.InlineInitialize();
//-->
</script>
<table id="EnterOrderModel.reportstoprofs_LP" class="dxeLoadingPanel" cellspacing="0" cellpadding="0" style="border-collapse:collapse;left:0px;top:0px;z-index:30000;display:none;">
<tbody>
<tr>
<td class="dx" style="padding-right:8px;"><img src="/DXR.axd?r=2_24-7rgYm" alt="" align="middle"></td>
<td class="dx" style="padding-left:0px;">Loading…</td>
</tr>
</tbody>
</table>
<div id="EnterOrderModel.reportstoprofs_LD" class="dxeLoadingDiv" style="left:0px;top:0px;z-index:29999;display:none;position:absolute;">
</div>
<script id="dxss_1042248493" type="text/javascript">
<!--
aspxAddHoverItems('EnterOrderModel.reportstoprofs',[[['dxeButtonEditButtonHover'],[''],['B-1'],,[['']],['Img']]]);
aspxAddPressedItems('EnterOrderModel.reportstoprofs',[[['dxeButtonEditButtonPressed'],[''],['B-1'],,[['']],['Img']]]);
aspxAddDisabledItems('EnterOrderModel.reportstoprofs',[[['dxeDisabled'],[''],['','I']],[['dxeDisabled dxeButtonDisabled'],[''],['B-1'],,[[{'spriteCssClass':'dxEditors_edtDropDownDisabled'}]],['Img']]]);
document.getElementById("EnterOrderModel.reportstoprofs_I").setAttribute("autocomplete", "off");
var dxo = new MVCxClientComboBox('EnterOrderModel.reportstoprofs');
window['EnterOrderModel.reportstoprofs'] = dxo;
dxo.callBack = function(arg) { ; };
dxo.RequireStyleDecoration();
dxo.styleDecoration.AddStyle('F','dxeFocused','');
dxo.incrementalFilteringMode='StartsWith';
dxo.isCallbackMode = true;
dxo.lastSuccessValue = 'AAAAA';
dxo.islastSuccessValueInit = true;
dxo.unobtrusiveValidationAttributes=eval(({'data-val-required':'Required','data-val':'true'}));
dxo.callbackUrl="/en-US/Orders/EnterOrder/ReportsToProf";
dxo.InlineInitialize();
//-->
</script>
<span class="commentText">*</span>
<span class="field-validation-valid" data-valmsg-for="EnterOrderModel.reportstoprofs" data-valmsg-replace="true"></span>
</td>
Selenium code to handle this complex dropdown selection
_driver is a variable of IWebDriver before use you have to initiate it e.g IWebDriver _driver = new ChromeDriver();
_driver.SelectDropDownByText(
clickId:"EnterOrderModel.reportstoprofs_B-1",
tableId:"EnterOrderModel.reportstoprofs_DDD_L_LBT",
visibleText:"Macccc Dongle");

How to fetch from a jquery datatable an array of second colum cells subject to checkbox in first column

I have a table as follows
<table id="vainTbl6" class="dtable" cellpadding="3" cellspacing="1" border="0">
<thead>
<tr><th>check</td><th>Morphosal</th><th>goat </th><th>the other</th></tr>
</thead>
<tbody id="tbdy">
<tr class="gradeX">
<td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%">-Approve the femuneration Gommiqee purpirt</td>
<td>pontpose</td></tr>
<tr class="gradeX">
<td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%">-Declare a final truce</td>
<td>More</td></tr>
<tr class="gradeX"><td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%">-Amend the articles of asscotonation</td>
<td>Four</td></tr>
<tr class="gradeX"><td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%">-Re-elect Bandanna la banana for warden</td>
<td>Floor</td></tr>
</tbody>
</table>
and the first column is a checkbox. I need to fetch all the second column cells where the checkbox in the first column is set to true
I tried using this, but to no avail.
function extractRowCell(divNode){
alert(divNode.id);
$('#tbdy tr td').each(function() {
alert('hello');
var aRowData = this.cells
alert(aRowData[1].firstChild.value);
return aRowData;
});
}
The call is as follows:
<a id="la" href='#' onclick='extractRowCell(this.parentNode)' style="position:absolute; top:280px; left:350px;">Votes & Concerns</a>
The alert in the function triggers though with the correct value.
TIA
To iterate over the td's simply do the following.
$('#tbdy tr td').each(function() {
alert( $(this).text() );
});
You can do this
<table><tbody id="tbdy">
<tr class="gradeX">
<td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%" class="item">-Approve the femuneration Gommiqee purpirt</td>
<td>pontpose</td></tr>
<tr class="gradeX">
<td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%" class="item">-Declare a final truce</td>
<td>More</td></tr>
<tr class="gradeX"><td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%" class="item">-Amend the articles of asscotonation</td>
<td>Four</td></tr>
<tr class="gradeX"><td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%" class="item">-Re-elect Bandanna la banana for warden</td>
<td>Floor</td></tr>
</tbody>
</table>
<button>Get</button>
<script>
$("button").click(function(){
var ret="";
$("#tbdy tr td:first").each(function()
{
if($("input:checked").length!=0)
{
ret=$("input:checked").parent().parent().find("td.item").text();
}
});
alert(ret);
});
</script>

Categories