How to perform dropdown in BMC Project using Webdriver - selenium-webdriver

I am not able to automate dropdown function in my BMC project. Tried lots of options. This will help me a lot. Please help..
<div id="WIN_0_913111809" class="df arfid913111809 ardbnCustomer Char" arid="913111809" artype="Char" ardbn="Customer" arlbox="0,4,114,17" style="z-index:993;top:2px; left:12px; width:309px; height:21px;" arwindowid="0">
<label id="label913111809" class="label f9" for="x-arid_WIN_0_913111809" style="top: 4px; left: 0px; width: 114px; height: 17px;">Customer*</label>
<textarea id="arid_WIN_0_913111809" class="text sr " cols="20" maxlen="255" style="top:0px; left:119px; width:164px; height:21px;" armenu="COM:CPY:Company=Oper/Cust-Q_ForInteractionCust" mstyle="2" arautoc="2" arautocak="0" arautoctt="400" rows="1" title="" wrap="off"></textarea>
<a class="btn btn3d menu" href="javascript:" style="top:0px; left:288px; width:21px; height:21px;">
<img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="Menu for Customer*" title="">
</a>
</div>​
<div class="MenuTableContainer" style="top: 20px;">
<table class="MenuTable" style="width: 386px;" cellspacing="0" cellpadding="0">
<tbody class="MenuTableBody">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<td class="MenuEntryNameHover" nowrap="">AARADHANA</td>
<td class="MenuEntryNoSubHover" arvalue="AARADHANA"></td>
</tr>
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
</tbody>
</table>
My screen looks like

This is not a select tag and is not designed to be one. It's an additional drop down menu element structured with tr and td tags. So using the Select class will not work.
Sample high level structure of a select tag:
<select>
<option>first option</option>
<option>second option</option>
</select
To solve your problem, You could simply use this:
driver.findElement(By.xpath("//div[#ardbn='Customer']//textarea")).clear();
driver.findElement(By.xpath("//div[#ardbn='Customer']//textarea")).sendKeys("AARADHANA");
Keep in mind that the text you are entering should be present in the menu. Entering a value that is not present in the list would result in the menu popping up and no value stored in the field, thereby throwing errors when you click on save since this is a mandatory field.
However if you do want to open the menu and choose something from there, you would have to wait for the element to appear and use one of these:
If the click needs to be performed on the tr
driver.findElement(By.xpath("//table[#class='MenuTable']//tr[td[.='AARADHANA']]")).click();
If the click needs to be performed on the td
driver.findElement(By.xpath("//table[#class='MenuTable']//tr//td[.='AARADHANA']")).click();
Be careful with this though, because
1. There may be many elements with the class 'MenuTable' that are hidden and if they are higher up in the hierarchy the script will fail.
2. If the first issue is not present and the customer you're trying to select is not visible you will have to scroll until the element is found before performing a click.
Highly recommend using the sendKeys option. Please ensure that you include code snippets to indicate what you've tried. This seems to be an issue with understanding the structure of the element in question.

Related

Bootstrap + AngularJS - Multiple page print job with common header/footer

I am using bootstrap with AngularJS and trying to ng-repeat out a table within the template I purchased and when over a certain amount is put into the orderInformation.items array I run into issues with how the print looks.
I want to be able to hit print and have a defined page heading and a defined page footer that will not change and should nest in the top and bottom of the print preview across all pages. The only content that will change is the items that AngularJS is doing an ng-repeat on.
How can this be done? I've been searching for days and days and nothing out there seems to work.
<div class="row">
<div class="col-md-12 card-box">
<table id="invoice-contents" style="width: 100%">
<thead>
<!-- This is where logo, company details, barcode go -->
</thead>
<tbody>
<table id="item-table" class="table m-t-30" style="border-bottom: 1px solid rgba(0,0,0,.1)">
<thead>
<!-- Invoice Item headers -->
</thead>
<tbody>
<tr ng-repeat="item in orderInformation.items">
<td style="text-align: center">{{$index + 1}}</td>
<td style="text-align: center">{{item.qty.ordered}}</td>
<td style="text-align: center">{{item.qty.shipped}}</td>
<td style="text-align: center">{{item.qty.backordered}}</td>
<td style="text-align: center">{{item.binLocation}}</td>
<td style="text-align: center">{{item.partNumber}} - {{item.description}}</td>
<td style="text-align: center">{{item.price.current * item.qty.shipped | number: 2}}</td>
<td style="text-align: right">{{item.price.extended * item.qty.shipped | number: 2}}</td>
</tr>
</tbody>
</table>
</tbody>
<tfoot>
<!-- Special order notes, totals, taxes, terms -->
</tfoot>
</table>
</div>
</div> <!-- end container -->
This doesn't work when I use the recommended CSS that I have found around:
thead { display: table-header-group; }
tbody { display: table-row-group; }
tfoot { display: table-footer-group; }
The documentation says a table can't have two thead so I know the problem lies there, but I can't find any other way to get a block to print top and bottom on all pages other than table-header-group.
A way round this through much trial and error was to product an onscreen display of a single invoice page with how ever many rows of data and then use display:none to hide a view that would only show during print with CSS #media print. I had to calculate how many rows would show on each page and use .splice() and nested ng-repeats to get it displaying properly.

How to use the aria combobox role with a grid element?

I'm trying to make an accessible calendar plugin where you can write the date in the input by hand or select it from a table. I'm using WAI-ARIA and I think I'm following the instructions correctly but the Chrome Developer Tools Accessibility audit gives me an error seen below
Instructions:
https://www.w3.org/TR/wai-aria-1.1/#combobox
https://www.w3.org/TR/wai-aria-1.1/#grid
Example:
https://www.w3.org/TR/wai-aria-practices-1.1/examples/combobox/aria1.1pattern/grid-combo.html
Error:
https://i.stack.imgur.com/OIX1f.png
My code:
<div class="container">
<label for="comboboxtextbox">the label</label>
<div role="combobox" aria-expanded="true" aria-owns="comboboxgrid" aria-haspopup="grid">
<input role="textbox" aria-multiline="false" id="comboboxtextbox" type="text" aria-controls="comboboxgrid">
</div>
<table role="grid" id="comboboxgrid">
<tbody>
<tr>
<th>one</th>
<th>two</th>
<th>three</th>
</tr>
<tr>
<td role="gridcell">1</td>
<td role="gridcell">2</td>
<td role="gridcell">3</td>
</tr>
</tbody>
</table>
</div>
The error message is saying that anything with a role of combobox has required child elements but it can’t find them in your markup. There’s been some changes to the combobox role so if you’re working from an older example it’ll be out of date. Try removing the role attributes from both the div and the table, and see if that helps.

angular smart-table plugin/directive wont work

I am trying to use smart-tables, Select row plugin, I have added 'smart-table' to my application, like so var myApp = angular.module('myApp', ['ui.bootstrap','smart-table']);
I have also changed the first line of the directive (since it didn't work to just copy-paste it), I changed this:
ng.module('smart-table').directive('stSelectRow', ['stConfig', function (stConfig)
To this: myApp.directive('stSelectRow', ['stConfig', function (stConfig) {
In my html I have this
<table st-table="displayedCollection" st-safe-src="safeCollection" class="table">
<thead>
<tr>
<th>Title</th>
<th>FieldOne</th>
<th>FieldTwo</th>
<th>FieldThree</th>
</tr>
</thead>
<tbody>
<tr st-select-row="row" st-select-mode="multiple" ng-repeat="row in displayedCollection">
<td> {{row.Title}} </td>
<td> {{row.FieldOne}} </td>
<td> {{row.FieldTwo}} </td>
<td> {{row.FieldThree}} </td>
</tr>
</tbody>
If I remove the st-select-row="row" st-select-mode="multiple" the table works, but obviously not the row selection
I am guessing I'm missing some dependency or something, I have only added smart-table.min.js to my application, but I think that should be enough, the directive (select row plugin) is added inside my app.js file. What could it be?
It is because the documentation on the site isn't exactly clear. But it does say
...and the class attribute st-selected is set on the tr element.
You have to define the CSS for st-selected for it to "work":
.st-selected{
background: #216eff !important;
color: white !important;
}

ngRepeat with Table: Change a cell's display text

I have a list of mails which I want to show in a grid (<table>). Some of these mails have attachments. For their corresponding rows, I would like to show an attachment icon in the attachment column. For rest, it should be empty.
JsFiddle: http://jsfiddle.net/6s4Z5/
My template is as follows:
<table id="resultTable">
<thead>
<tr>
<th ng-repeat="columnId in schema.columnOrder">
<img src="icon_attach.png" ng-if="columnId == 'hasAttachments'">
{{schema.columns[columnId].displayText}}
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in results.mails">
<td ng-repeat="columnId in schema.columnOrder">
<img src="icon_attach.png" ng-if="columnId == 'hasAttachments' && row.hasAttachments">
<span ng-if="columnId != 'hasAttachments'" >{{ row[columnId] }}</span>
</td>
</tr>
</tbody>
</table>
where schema.columnOrder is an array of columnIds to be shown in the table.
This template is working but is this the best way to implement this? Moreover, I have to add an extra <span> for ng-if statement. Can that also be removed?
You pretty much can change it to something like:
<span ng-if='your check'><img src=''/>{{row[columnId}}</span>
You could set (in the controller) the value of the column hasAttachments to be the image you want to display there.

angularJS - Repeating tr's in a table, but dynamically adding more rows while looping

Since examples always tell more then just words here is what I would like to do in another language
<tr>
<c:forEach items="${items}" var="item">
<td>...</td>
<td>...</td>
<td>...</td>
<c:if test="${item.showWarning}">
</tr><tr><td colspan="3">${item.warning}</td>
</c:if>
</tr>
So this will loop over a set of items and show some properties of these items. If there is a warning, a new row will be added underneath the current row in which the warning will be shown. However, how can I do this in angularJs? If I put a ng-repeat on the tr, it will stop at the first end tag of tr. I have read on some other threads that this is not very easily done, but how can it be done? And yes, I really do want to use a table. Here is my contrived example with angularjs which is obviously not working as I would like it to. Any pointers how this can be done?
JSBin example with tr-ng-repeat
Currently (1.0.7/1.1.5) you can't output data outside the ng-repeat, but version 1.2(see youtube video AngularJS 1.2 and Beyond at 17:30) will bring the following syntax(adapted to your example):
<tr ng-repeat-start="item in items">
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
<tr ng-repeat-end ng-show="item.showWarning">
<td colspan="3">{{item.warning}}</td>
</tr>
The idea is that whatever is between -start and -end will be repeated including the -end element.
One solution that I can think of is having multiple tbody tags within the same table. Here is a discussion on the use of multiple tbody tags within the same table.
So, for your issue, you could have the following setup:
<table ng-controller="ItemController">
<thead>
<th>Name</th>
<th>Description</th>
<th>warning?</th>
</thead>
<tbody ng-repeat="item in items">
<tr>
<td>{{item.name}}</td>
<td>{{item.description}}</td>
<td>{{item.warning}}</td>
</tr>
<tr ng-show="item.warning">
<td colspan="3" style="text-align: center">Warning !!!</td>
</tr>
</tbody>
</table>
Repeat the table body as many times as there are entries for the table and within it have two rows - one to actually display the row entry and one to be displayed conditionally.
You can repeat over the tbody
<tbody ng-repeat="item in items">
<tr>
<td>{{item.name}}</td>
<td>{{item.description}}</td>
<td>{{item.warning}}</td>
</tr>
<tr ng-show="item.warning">
<td colspan="3">Warning !!!</td>
</tr>
</tbody>
Also you do not need to wrap the ng-show expression in {{}}, you can just use item.warning

Resources