Here I'm trying to working an action button (Edit) in angular material expandable table each row. When I click edit button it's not work but row is become expanded.
ISSUE:-
When click Edit button should be work on click and row should not be expanded.
When click on row's other part without Edit button then only row will be expanded.
Here is my code:
viewuser.component.html
<table mat-table [dataSource]="tableData" multiTemplateDataRows class="mat-elevation-z8"><ng-container matColumnDef="Name">
<th mat-header-cell *matHeaderCellDef>Name </th>
<td mat-cell *matCellDef="let element">{{ element.f_name }} {{ element.l_name}} </td></ng-container><ng-container matColumnDef="Designation">
<th mat-header-cell *matHeaderCellDef>Designation </th>
<td mat-cell *matCellDef="let element"> {{ element.title }}</td></ng-container><ng-container matColumnDef="Department">
<th mat-header-cell *matHeaderCellDef>Department </th>
<td mat-cell *matCellDef="let element"> {{element.dept_name}}</td></ng-container><ng-container matColumnDef="Edit">
<th mat-header-cell *matHeaderCellDef> Edit</th>
<td mat-cell *matCellDef="let element"><button mat-icon-button><mat-icon color="primary">border_color</mat-icon></button> </td></ng-container><ng-container matColumnDef="expandedDetail"><td mat-cell *matCellDef="let element" [attr.colspan]="columnsToDisplay"><div class="example-element-detail" [#detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'"><!--expanded content goes here --></div></td></ng-container><tr mat-header-row *matHeaderRowDef="columnsToDisplay"></tr><tr mat-row *matRowDef="let element; columns: columnsToDisplay;"class="example-element-row" [class.example-expanded-row]="expandedElement === element"(click)="expandedElement = expandedElement === element ? null : element"></tr><tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="example-detail-row"></tr></table>
viewuser.component.ts
columnsToDisplay: string[] = ['Name','Designation','Department','Edit'];
Here is angular material reference .. https://stackblitz.com/angular/ygdrrokyvkv?file=app%2Ftable-expandable-rows-example.html
Related
In below html code when i focus on any button. All 3 button are read instead of just focused one.
<table>
<tr>
<th >Column 1</th>
<th >Column2</th>
<th >
<button>Button1</button>
<button>Button2</button>
<button>Button3</button>
</th>
</tr>
<tr>
<td>Row1</td>
<td>Row2</td>
<td>Row3
<div>
<button>Button1</button>
<button>Button2</button>
<button>Button3</button>
</div>
</td>
</tr>
</table>
Is this JAWS issue. or am i missing something in my code.
I'm looking for a way to check if text exists in a table cell.
I have no problem when there is only simple text in the cell, but my table cell has additional html tags and table.
I would like to check if the url exists (foo.bar.com) and then execute some logic or move to the next row.
Here is the one row snippet:
<tr bgcolor="#ffffff">
<td align="right" valign="top" nowrap="nowrap">99</td>
<td align="left" valign="top">
http://foo.bar.com<br>
<div style="margin-top: 8px">Show Details</div>
<div id="details_1" style="display: none;">
<table class="url-tracking-details">
<tbody>
<tr>
<td align="left" valign="top" nowrap="nowrap">Product:</td>
<td align="left" valign="top" nowrap="nowrap">- foo <br>- bar <br>- foobar</td>
</tr>
<tr>
<td align="left" valign="top" nowrap="nowrap">Version:</td>
<td align="left" valign="top" nowrap="nowrap">foo 4.2</td>
</tr>
<tr>
<td align="left" valign="top" nowrap="nowrap">Categorization:</td>
<td align="left" valign="top" nowrap="nowrap">- bar<br></td>
</tr>
</tbody>
</table>
</div>
</td>
<td align="center" valign="top" nowrap="nowrap">Closed</td>
<td align="center" valign="top" nowrap="nowrap">25/May/2022</td>
<td align="center" valign="top" nowrap="nowrap">25/May/2022</td>
</tr>
I've tried many things, including:
store | http://foo.bar.com | url
store text | xpath=//form/table/tbody/tr[2]/td[2] | cell
execute script | if (${cell}.startsWith(${url})) { return true; } else { return false }; | x
assert | x | true
but I'm getting 'Failed: Unexpected token in JSON at position 20'
So the full xpath for that url:
/html/body/div[2]/div[3]/div[2]/div[2]/div/div/div/div[2]/div1/div/div/form/table/tbody/tr[2]/td[2]/text()
How can I catch just this text?
I got it.
store | http://foo.bar.com | url
verify element present | xpath=//form/table/tbody/tr[2]/td[2][text()='${url}']
and here is an example with conditional logic:
the verify element present was changed to store xpath count and then assigned to the variable out (1 if true, 0 if false).
I am trying to select based on text, I use the following to select
$("div[class='ui-datatable-tablewrapper']").find("span:contains('Person Name')")
i get the following error:
Caused by: org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified
I believe it's because of the "contains" selector in jquery. How do I achieve the same in geb.
Html:
<div class="ui-datatable-tablewrapper">
<table role="grid">
<thead id="searchForm:singleStaffDT_head">
<tr role="row">
<th id="searchForm:singleStaffDT:j_id_7s" class="ui-state-default" role="columnheader"
aria-label="Person ID" scope="col" style="width:15%">
<span class="ui-column-title">Person ID</span>
</th>
<th id="searchForm:singleStaffDT:j_id_7u" class="ui-state-default" role="columnheader"
aria-label="Person Name" scope="col" style="width:25%">
<span class="ui-column-title">Person Name</span>
</th>
<th id="searchForm:singleStaffDT:j_id_7w" class="ui-state-default" role="columnheader"
aria-label="Organization" scope="col" style="width:25%">
<span class="ui-column-title">Organization</span>
</th>
<th id="searchForm:singleStaffDT:j_id_7y" class="ui-state-default" role="columnheader"
aria-label="Staff Role" scope="col" style="width:25%">
<span class="ui-column-title">Staff Role</span>
</th>
<th id="searchForm:singleStaffDT:j_id_80" class="ui-state-default" role="columnheader"
aria-label="" scope="col" style="width:10%">
<span class="ui-column-title">Action
<BR />[Select]</span>
</th>
</tr>
</thead>
<tbody id="searchForm:singleStaffDT_data" class="ui-datatable-data ui-widget-content">
<tr class="ui-widget-content ui-datatable-empty-message">
<td colspan="5"></td>
</tr>
</tbody>
</table>
</div>
For a "contains" search, you want to write your code in a similar pattern to this:
$("span", text: contains("Person Name"))
You could also do something like this in your page object (i think!):
personName { $('span').find(text: 'Person Name') }
Or:
personName { find('span', text: 'Person Name') }
I'm trying to get the value qty of products shipped to display as an additional column in the invoice report. Not sure if its as simple as finding out what variable it is or what. Is there any easy way to reference what variables are available for the current views?
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th class="hidden">Source Document</th>
<th class="text-right">Ordered</th>
<th class="text-right">Shipped</th>
<th class="text-right">Backorder</th>
<th class="text-right">Unit Price</th>
<th t-if="display_discount" class="text-right">Disc.(%)</th>
<th class="text-right">Extended Price</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line_ids" t-as="l">
<td><span t-field="l.name"/></td>
<td class="hidden"><span t-field="l.origin"/></td>
<td class="text-right">
<span t-field="l.quantity"/>
<span t-field="l.uom_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="o.delivery_count"/>
</td>
<td class="text-right">
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td t-if="display_discount" class="text-right">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal" t-options="{"widget": "monetary", "display_currency": o.currency_id}"/>
</td>
</tr>
</tbody>
I don't exactly know what you mean with "products shipped" but you can get the quantity of the invoice lines to your report like this:
<t t-foreach="o.invoice_line_ids" t-as="l">
<span t-field="l.quantity"/>
</t>
Same for the stock picking lines quantity:
<t t-foreach="o.move_lines" t-as="l">
<span t-field="l.product_uom_qty"/>
</t>
One easy way to get the variable names is to activate the develop mode and placing the cursor over a field label.
You can also go to Settings->Database Structure->Models then just pick your needed model to see the variable names (field names).
Here is my HTML Script:
How to capture the link element in the tenth row?
HTML image
<table id="dataTableParticipantSearchResults" class="display" width="100%" cellspacing="0" cellpadding="0" border="0">
<thead>
<tr align="left">
<th class="ui-state-default" width="20%" style="width: 154px;">
<div class="DataTables_sort_wrapper"></div>
</th>
<th class="ui-state-default" width="20%" style="width: 96px;"></th>
<th class="ui-state-default" width="15%" style="width: 69px;"></th>
<th class="ui-state-default" width="10%" style="width: 44px;"></th>
<th class="ui-state-default" width="20%" style="width: 156px;"></th>
<th class="ui-state-default" width="15%" style="width: 68px;"></th>
</tr>
</thead>
<tbody>
<tr class="odd" align="left">
<td></td>
</tr>
2.How to store that value, so that i can call the same value to access the link element?
You can always find these kinds of hyperlinks by first identifying the root table id- in this case it will be like this:
WebElement table = driver.findelement(by.id("dataTableParticipantSearchResults"));
Now you can use Xpath or Css Selector to select the link
try this:
table.findelement(by.cssSelector("a[href='LINK']")).click();
or try
table.findelement(by.linktext("LINK")).click();
or try
table.findelement(by.xpath(".//*[#id='dataTableParticipantSearchResults']/tbody/tr/td[0]")).click();
let me know if these work....cheers !
U can store the value in a WebElement and call any number of times.
WeElement link = table.findelement(by.xpath(".//*[#id='dataTableParticipantSearchResults']/tbody/tr/td[9]"));
now call it any number of times:
link.click();---------1st time
link.click();--------- 2nd time
and so on.....cheers !