I have a jsa page Test.jsp page .There are two modal in the page.data is dynamically loded in modal. second modal open at first modal link.when both modal are open when i close second modal first modal also close and also scroll is not work correctly.
FIRST MODAL
<div id="panelModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Department Details</h4>
</div>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover">
<tbody>
<tr>
<td class="col-md-2">Panel Name</td>
<td class="col-md-2">
<label id="panel1" text=""></label></td>
<td class="col-md-2">Panel Price</td>
<td class="col-md-2">
<label id="price1" text=""></label></td>
<td class="col-md-2">Description</td>
<td class="col-md-2">
<label id="description1"></label></td>
</tr>
<tr>
<td class="col-md-2">Mapped Test </td>
<td class="col-md-2" id="tests">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
SECOND MODAL
<div id="testModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Test Details</h4>
</div>
<!-- <div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-body"> -->
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover">
<tbody>
<tr>
<td class="col-md-2">Test Common Name</td>
<td class="col-md-2">
<label id="testName1" text=""></label></td>
<td class="col-md-2">Test Technical Name</td>
<td class="col-md-2">
<label id="technicalName"></label></td>
<td class="col-md-2">Test Area</td>
<td class="col-md-2">
<label id="testArea1"></label></td>
</tr>
<tr>
<td class="col-md-2">Technology Long Form</td>
<td class="col-md-2">
<label id="testCategory1"></label></td>
<td class="col-md-2">Technology Short Form</td>
<td class="col-md-2">
<label id="testCategory2"></label></td>
<td class="col-md-2">Sub Test Technology</td>
<td class="col-md-2">
<label id="subTestCategory1"></label></td>
</tr>
<tr>
<td class="col-md-2">TAT</td>
<td class="col-md-2">
<label id="tat1"></label></td>
<td class="col-md-2">Test MRP</td>
<td class="col-md-2">
<label id="testMrp1"></label></td>
<td class="col-md-2">Specimen Type</td>
<td class="col-md-2" id="specimenType1">
</td>
</tr>
<tr>
<td class="col-md-2">Preservation</td>
<td class="col-md-2">
<label id="preservation1"></label></td>
<td class="col-md-2">Comment</td>
<td class="col-md-2">
<label id="comment1"></label></td>
<td class="col-md-2">NABL Accredited</td>
<td class="col-md-2">
<label id="nablAccredited"></label></td>
</tr>
<tr>
<td class="col-md-2">Test Type</td>
<td class="col-md-2">
<label id="testType1"></label></td>
<td class="col-md-2">Site</td>
<td class="col-md-2">
<label id="site1"></label></td>
<td class="col-md-2">Department</td>
<td class="col-md-2">
<label id="department1"></label></td>
</tr>
<tr>
<td class="col-md-2">Sub Department</td>
<td class="col-md-2">
<label id="subdepartment1"></label></td>
<td class="col-md-2">Description</td>
<td class="col-md-2">
<label id="description1"></label></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
You can use z-Index to solve your problem. For example:
var zIndex = 1040 + (10 * $('.modal:visible').length);
$(this).css('z-index', zIndex);
setTimeout(function() {
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
}, 0);
Here is jsFiddle Demo
Related
Views.py
def advance_filter(request):
user_list = SarnarLogs.objects.all()
user_filter = UserFilter(request.GET)
return render(request, 'advance_filter.html', {'filter': user_filter})
Template: Advance_filter.html
<form method="get">
<div class="well">
<h4 style="margin-top: 0">Filter</h4>
<div class="row">
<div class="form-group col-sm-4 col-md-3">
{{ filter.form.source.label_tag }}
{% render_field filter.form.source class="searchfield" %}
</div>
<div class="form-group col-sm-4 col-md-3">
{{ filter.form.destination.label_tag }}
{% render_field filter.form.destination class="searchfield" %}
</div>
<div class="form-group col-sm-4 col-md-3">
{{ filter.form.port.label_tag }}
{% render_field filter.form.port class="searchfield" %}
</div>
<div class="form-group col-sm-4 col-md-3">
{{ filter.form.request_no.label_tag }}
{% render_field filter.form.request_no class="searchfield" %}
</div>
</div>
<button type="submit" class="btn btn-primary" placeholder="Search" aria-label="Search" name="q" value='{{ request.GET.q }}'>
<span class="glyphicon glyphicon-search"></span> Search
</button>
</div>
</form><br>
<div class="col-12">
<div class="card my-4">
<div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
<div class="bg-gradient-primary shadow-primary border-radius-lg pt-4 pb-3">
<h6 class="text-white text-capitalize ps-3">HUB Requests</h6>
</div>
</div>
<div class="card-body px-0 pb-2">
<div class="table-responsive p-0">
<table class="table align-items-center mb-0">
<thead>
<tr>
<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">ID</th>
<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 ps-2">SOURCE</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">DESTINATION</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">PORT</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">REQUEST TYPE</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">REQUEST_NO</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">REQUESTER</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">START DATE</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">EXPIRY DATE</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Days Left</th>
<th class="text-secondary opacity-7"></th>
</tr>
</thead>
<tbody>
{% for user in filter.qs %}
<tr>
<td>
<div class="d-flex px-2 py-1">
<div class="d-flex flex-column justify-content-center">
<h6 class="mb-0 text-sm">{{user.id}}</h6>
</div>
</div>
</td>
<td>
<p class="text-xs font-weight-bold mb-0">{{user.source}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.destination}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.port}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.request_type}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.request_no}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.requester}}</p>
</td>
<td class="align-middle text-center">
<span class="text-secondary text-xs font-weight-bold">{{user.start_date|date:'d-m-Y'}}</span>
</td>
<td class="align-middle text-center">
<span class="text-secondary text-xs font-weight-bold">{{user.expiry_date|date:'d-m-Y'}}</span>
</td>
<td class="align-middle text-center">
<span class="text-secondary text-xs font-weight-bold">{{ user.expiry_date|timeuntil:user.start_date }}</span>
</td>
</tr>
{% empty %}
<tr>
<td colspan="5">No data</td>
</tr>
{% endfor %}
</tbody>
Any solution to load the page with search boxes and later when user provide inputs and hits the seach to display the data. Problem is that there are millions of records and page is consuming time to load up.
Appriciate if someone can provide insight in resolving it.
new to bootstrap and experimenting on a pet project. am a bit at my wits ends here.
my understanding is if you have <div class="col-sm-12 col-lg-5"> and <div class="col-sm-12 col-lg-7 "> on small screen each would take a new row (12 cols). vs on a large screen they'd share the row (5+7). in my code the second table(fruits) is supposed to share row with the chart on large screens and split on small screen but when I try small screens in debugging mode, the second column with the chart gets pushed out of the parent column (off screen). I have no clue what exactly is wrong here. any help would be appreciated
bellow is a portion of the code
<div class="container">
<div class="row">
<div class="media content-section col-sm-12 col-md-12 col-lg-12">
<form action="" method="post">
{% csrf_token %}
<label class="switch"
><input type="checkbox" id="togBtn" />
<div class="slider round">
<!--ADDED HTML --><span class="on">BUY</span
><span class="off">SELL</span
><!--END-->
</div></label
>
<div class="table-responsive-md">
<table class="table table-sm table-bordered tableformat">
<thead>
SUMMARY
<small class="text-muted"
>(edit cells to adjust position)</small
>
<tr>
<th scope="col">col 1</th>
<th scope="col">col 2</th>
<th scope="col">col 3</th>
<th scope="col">col 4</th>
<th scope="col">col 5</th>
<th scope="col">col 6</th>
<th scope="col">col 7</th>
<th scope="col">col 8</th>
<th scope="col">col 9</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td width="60">
<input
type="text"
maxlength="10"
width="50%"
placeholder="1"
size="10"
/>
</td>
<td width="60">
<input
type="text"
maxlength="10"
width="50%"
size="10"
placeholder="2"
/>
</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md">
<button
type="button"
class="btn btn-primary btn-sm"
type="submit"
>
update position
</button>
<button
type="button"
class="btn btn-primary btn-sm"
type="submit"
>
reset to default
</button>
</div>
</div>
</form>
</div>
</div>
<div class="row">
<div class="media content-section col-sm-12-col-md-12 col-lg-12">
<div class="col-sm-12 col-lg-5">
<div class="table-responsive-md">
<table
class="table table-sm table-bordered tableformat text-center"
>
<thead>
fruits
<small class="text-muted"
>(hover on terms for quick definitions)</small
>
<tr>
<th scope="col">mango</th>
<th scope="col">banana</th>
<th scope="col">apple</th>
<th scope="col">peach</th>
<th scope="col">grapes</th>
<th scope="col">lemon</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="chart col-sm-12 col-lg-7 overflow-auto">
<div style="width: 560; height: 400;">
<canvas id="plchart"></canvas>
</div>
</div>
</div>
</div>
here is how it looks in debugging mode on large screen vs on small screen. I have in the meta tag <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
solved it. I missed the inner row before the cols.
essentially should be something like container->row->outer col->inner row -> inner-cols. I was doing container->row-> outer col -> inner cols
I have a HTML table with some rows of input fields. Each input field has a value.
The input field I am looking for is any input field which contains the text "filter"
The actual text is "filter2" or it could be "filter3"
Can i use the contains keyword in the Xpath to find "filter" for the #value attribute?
The XPATH i have constructed is:
//table[#id="reporting_add_report_tab_manual_ct_match_filters"]/tbody//tr//td//input[#value="filter2"]
I would like to find the input field where it has filter in the value attribute, exclude the number 2
The HTML snippet is:
<table id="reporting_add_report_tab_manual_ct_match_filters" class="GJPPK2LBAV border" cellspacing="0"
__gwtcellbasedwidgetimpldispatchingfocus="true" __gwtcellbasedwidgetimpldispatchingblur="true">
<thead aria-hidden="false">
<colgroup>
<tbody style="">
<tr class="GJPPK2LBCD GJPPK2LBMD" __gwt_subrow="0" __gwt_row="0">
<td class="GJPPK2LBBD GJPPK2LBDD GJPPK2LBED">
<div __gwt_cell="cell-gwt-uid-684" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBBD GJPPK2LBDD">
<div __gwt_cell="cell-gwt-uid-685" style="outline-style:none;">
<span>
<input type="text" tabindex="-1" value="rule1"/>
</span>
<span>
</div>
</td>
<td class="GJPPK2LBBD GJPPK2LBDD GJPPK2LBOD">
</tr>
<tr class="GJPPK2LBCE" __gwt_subrow="0" __gwt_row="1">
<td class="GJPPK2LBBD GJPPK2LBDE GJPPK2LBED">
<div __gwt_cell="cell-gwt-uid-684" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBBD GJPPK2LBDE">
<div __gwt_cell="cell-gwt-uid-685" style="outline-style:none;">
<span>
<input type="text" tabindex="-1" value="filter2"/>
</span>
<span>
<div style="color:red;font-style:italic;"/>
</span>
</div>
</td>
<td class="GJPPK2LBBD GJPPK2LBDE GJPPK2LBOD">
</tr>
</tbody>
<tbody style="display: none;">
<tfoot style="display: none;" aria-hidden="true"/>
</table>
Thanks,
Riaz
//table[#id="reporting_add_report_tab_manual_ct_match_filters"]/tbody/tr/td//input[#value!="filter2"][contains(#value,"filter")]
I have a table of 6 columns and some rows. For row 1 Col0 has a checkbox. Col 2 has the text "Name" and col 5 has the text "CRM"
Row 2 col 2 has the text "Address" and has the text "CRM"
Row 7 col 2 has the text "Name" and col 5 has the text "ESCR"
The pattern goes on like this with rows of date.
I would like to select the checkbox from col0 where col2 has the text "Name" and col5 has the text "CRM"
How do i do this using XPATH please?
I have a made a start and I can identify the text "CRM" from col5. I need to get the correct row so I need to find "Name" and then go up to the checkbox.
My XPATH is:
//table[#id="data_configuration_variables_ct_fields_body"]/tbody/tr//td/div/span[#title="CRM" and contains(text(), "CRM")]
I would like to include the text "Name" in the XPATH and then include the checkbox.
I can then select the correct row.
The HTML sample is (sorry for the long HTML - i don't know how to provide it in a shorter way):
<table id="data_configuration_variables_ct_fields_body" cellspacing="0" style="table-layout: fixed; width: 100%;">
<colgroup>
<tbody>
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="0">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-1130" style="outline-style:none;" tabindex="0">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1131" style="outline-style:none;">
<span class="linkhover" title="Name" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;color:#00A;cursor:pointer;">Name</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1132" style="outline-style:none;">
<span class="" title="Name" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">Name</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1133" style="outline-style:none;">
<span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1134" style="outline-style:none;">
<span title="CRM" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">CRM</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBBH">
</tr>
<tr class="GJPPK2LBEH" __gwt_subrow="0" __gwt_row="1">
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-1130" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1131" style="outline-style:none;">
<span class="linkhover" title="Address" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;color:#00A;cursor:pointer;">Address</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1132" style="outline-style:none;">
<span class="" title="Address" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">Address</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1133" style="outline-style:none;">
<span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1134" style="outline-style:none;">
<span class="" title="CRM" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">CRM</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBBH">
</tr>
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="2">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-1130" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1131" style="outline-style:none;">
<span class="linkhover" title="DOB" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;color:#00A;cursor:pointer;">DOB</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1132" style="outline-style:none;">
<span class="" title="DOB" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">DOB</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1133" style="outline-style:none;">
<span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1134" style="outline-style:none;">
<span class="" title="CRM" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">CRM</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBBH">
</tr>
<tr class="GJPPK2LBEH" __gwt_subrow="0" __gwt_row="3">
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-1130" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1131" style="outline-style:none;">
<span class="linkhover" title="Phone" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;color:#00A;cursor:pointer;">Phone</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1132" style="outline-style:none;">
<span class="" title="Phone" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">Phone</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1133" style="outline-style:none;">
<span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1134" style="outline-style:none;">
<span class="" title="CRM" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">CRM</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBBH">
</tr>
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="4">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-1130" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1131" style="outline-style:none;">
<span class="linkhover" title="Email" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;color:#00A;cursor:pointer;">Email</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1132" style="outline-style:none;">
<span title="Email" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">Email</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1133" style="outline-style:none;">
<span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1134" style="outline-style:none;">
<span class="" title="CRM" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">CRM</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBBH">
<div __gwt_cell="cell-gwt-uid-1135" style="outline-style:none;">
<span class="" title="DM" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">DM</span>
</div>
</td>
</tr>
<tr class="GJPPK2LBEH" __gwt_subrow="0" __gwt_row="5">
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-1130" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1131" style="outline-style:none;">
<span class="linkhover" title="ACVSEQ" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;color:#00A;cursor:pointer;">ACVSEQ</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1132" style="outline-style:none;">
<span class="" title="ACVSEQ" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">ACVSEQ</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1133" style="outline-style:none;">
<span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH">
<div __gwt_cell="cell-gwt-uid-1134" style="outline-style:none;">
<span class="" title="CRM" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">CRM</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBFH GJPPK2LBBH">
<div __gwt_cell="cell-gwt-uid-1135" style="outline-style:none;">
<span class="" title="DM" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">DM</span>
</div>
</td>
</tr>
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="6">
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBHG">
<div __gwt_cell="cell-gwt-uid-1130" style="outline-style:none;">
<input type="checkbox" tabindex="-1"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1131" style="outline-style:none;">
<span class="linkhover" title="Name" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;color:#00A;cursor:pointer;">Name</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1132" style="outline-style:none;">
<span class="" title="Name" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">Name</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1133" style="outline-style:none;">
<span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;"/>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG">
<div __gwt_cell="cell-gwt-uid-1134" style="outline-style:none;">
<span class="" title="ESCR" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">ESCR</span>
</div>
</td>
<td class="GJPPK2LBEG GJPPK2LBGG GJPPK2LBBH">
<div __gwt_cell="cell-gwt-uid-1135" style="outline-style:none;">
<span class="" title="DM" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">DM</span>
</div>
</td>
</tr>
<tr class="GJPPK2LBEH" __gwt_subrow="0" __gwt_row="7">
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="8">
<tr class="GJPPK2LBEH" __gwt_subrow="0" __gwt_row="9">
<tr class="GJPPK2LBFG" __gwt_subrow="0" __gwt_row="10">
</tbody>
</table>
Thanks,
Riaz
Don't overcomplicate things (broke into multiple lines for readability):
//table[#id="data_configuration_variables_ct_fields_body"]
//tr[td[2]//span = "Name" and td[5]//span = "CRM"]
/td[1]/div/input
Here we are locating the tr elemen having a span with text Name in the second cell and span with text CRM in the fifth. After getting the appropriate row, we are locating the input element.
No need to go down and up the tree as #BenChand suggested.
I have a table with 4 rows. There is a checkbox in the first column for each row. 4 checkboxes as there are 4 rows. A checkbox for Name, Address, DOB, Phone
I want to select all of the checkboxes. My code does this as I can see the checkboxes being ticked when i run my Selenium Python code.
When all checkboxes are ticked it throws the error:
StaleElementReferenceException: Message: Element is no longer valid
My code method implentation is as follows:
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
def click_all_variables_from_variables_section(self):
#checkboxes = self.driver.find_elements_by_css_selector("#reporting_add_report_tab_manual_ct_vars_usn input[type='checkbox']")
#checkboxes = WebDriverWait(self.driver, 20).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "'#reporting_add_report_tab_manual_ct_vars_usn input[type='checkbox']'")))
checkboxes = self.driver.find_elements(By.XPATH, '//table[#id="reporting_add_report_tab_manual_ct_vars_usn"]//input[#type="checkbox"]')
for checkbox in checkboxes:
checkbox.click()
return self
From my code you can see some comments of what else I have tried e.g. WebDriverWait. When i tried WebDriverWait it stayed stuck in a loop for a very long time. I had to close to the browser to exit.
The HTML is:
<table id="reporting_add_report_tab_manual_ct_vars_usn" class="GLKP2TGBJE" cellspacing="0" __gwtcellbasedwidgetimpldispatchingfocus="true" __gwtcellbasedwidgetimpldispatchingblur="true">
<thead aria-hidden="false">
<colgroup>
<tbody style="">
<tr class="GLKP2TGBCD GLKP2TGBJD" __gwt_subrow="0" __gwt_row="0">
<td class="GLKP2TGBBD GLKP2TGBDD GLKP2TGBED GLKP2TGBKD">
<div __gwt_cell="cell-gwt-uid-488" style="outline-style:none;">
<input type="checkbox" tabindex="-1" />
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDD GLKP2TGBKD">
<div __gwt_cell="cell-gwt-uid-489" style="outline-style:none;">Name</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDD GLKP2TGBKD">
<div __gwt_cell="cell-gwt-uid-490" style="outline-style:none;">
<select tabindex="-1">
<option selected="selected" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDD GLKP2TGBKD">
<div __gwt_cell="cell-gwt-uid-491" style="outline-style:none;">
<select tabindex="-1">
<option selected="selected" value="" />
</select>
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDD GLKP2TGBOD GLKP2TGBKD">
<div __gwt_cell="cell-gwt-uid-492" style="outline-style:none;">
<input type="text" tabindex="-1" value="" />
</div>
</td>
</tr>
<tr class="GLKP2TGBCE" __gwt_subrow="0" __gwt_row="1">
<td class="GLKP2TGBBD GLKP2TGBDE GLKP2TGBED">
<div __gwt_cell="cell-gwt-uid-488" style="outline-style:none;">
<input type="checkbox" tabindex="-1" />
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDE">
<div __gwt_cell="cell-gwt-uid-489" style="outline-style:none;">Address</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDE">
<div __gwt_cell="cell-gwt-uid-490" style="outline-style:none;">
<select tabindex="-1">
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDE">
<div __gwt_cell="cell-gwt-uid-491" style="outline-style:none;">
<select tabindex="-1">
<option selected="selected" value="" />
</select>
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDE GLKP2TGBOD">
<div __gwt_cell="cell-gwt-uid-492" style="outline-style:none;">
<input type="text" tabindex="-1" value="" />
</div>
</td>
</tr>
<tr class="GLKP2TGBCD" __gwt_subrow="0" __gwt_row="2">
<td class="GLKP2TGBBD GLKP2TGBDD GLKP2TGBED">
<div __gwt_cell="cell-gwt-uid-488" style="outline-style:none;">
<input type="checkbox" tabindex="-1" />
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDD">
<div __gwt_cell="cell-gwt-uid-489" style="outline-style:none;">DOB</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDD">
<div __gwt_cell="cell-gwt-uid-490" style="outline-style:none;">
<select tabindex="-1">
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDD">
<div __gwt_cell="cell-gwt-uid-491" style="outline-style:none;">
<select tabindex="-1">
<option selected="selected" value="" />
</select>
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDD GLKP2TGBOD">
<div __gwt_cell="cell-gwt-uid-492" style="outline-style:none;">
<input type="text" tabindex="-1" value="" />
</div>
</td>
</tr>
<tr class="GLKP2TGBCE" __gwt_subrow="0" __gwt_row="3">
<td class="GLKP2TGBBD GLKP2TGBDE GLKP2TGBED">
<div __gwt_cell="cell-gwt-uid-488" style="outline-style:none;">
<input type="checkbox" tabindex="-1" />
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDE">
<div __gwt_cell="cell-gwt-uid-489" style="outline-style:none;">Phone</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDE">
<div __gwt_cell="cell-gwt-uid-490" style="outline-style:none;">
<select tabindex="-1">
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDE">
<div __gwt_cell="cell-gwt-uid-491" style="outline-style:none;">
<select tabindex="-1">
<option selected="selected" value="" />
</select>
</div>
</td>
<td class="GLKP2TGBBD GLKP2TGBDE GLKP2TGBOD">
<div __gwt_cell="cell-gwt-uid-492" style="outline-style:none;">
<input type="text" tabindex="-1" value="" />
</div>
</td>
</tr>
</tbody>
<tbody style="display: none;">
<tr>
<td align="center" colspan="5">
<div>
<div style="width: 100%; height: 100%; padding: 0px; margin: 0px; display: none;" aria-hidden="true">
<div style="width: 100%; height: 100%; display: none;" aria-hidden="true">
<div class="gwt-Label">No data to display.</div>
</div>
</div>
<div style="width: 100%; height: 100%; padding: 0px; margin: 0px;" aria-hidden="false">
<div class="GLKP2TGBBE" style="width: 100%; height: 100%;" aria-hidden="false">
<div class="gwt-Label">Loading...</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
<tfoot style="" aria-hidden="false">
</table>
The full error trace is:
Traceback (most recent call last):
File "C:\Webdriver\ClearCore\TestCases\ReportingPage_TestCase.py", line 53, in test_add_matches_report
reports_page.click_all_variables_from_variables_section()
File "C:\Webdriver\ClearCore\Pages\reports.py", line 75, in click_all_variables_from_variables_section
checkbox.click()
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 65, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 402, in _execute
return self._parent.execute(command, params)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 175, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
raise exception_class(message, screen, stacktrace)
StaleElementReferenceException: Message: Element is no longer valid
I have also tried waiting for the table to load first then click the checkboxes.
My code is:
WebDriverWait(self.driver, 20).until(EC.presence_of_all_elements_located((By.ID, '//table[#id="reporting_add_report_tab_manual_ct_vars_usn"]')))
checkboxes = self.driver.find_elements(By.XPATH, '//table[#id="reporting_add_report_tab_manual_ct_vars_usn"]//input[#type="checkbox"]')
for checkbox in checkboxes:
checkbox.click()
This one throws a TimeoutException
How can i solve this, click all of the checkboxes without there being any errors?
Thanks,
Riaz