How to create ng-bootstrap date range picker popup from button element - angular5

I am trying to add functionality for the daterangepicker to allow for filtering of a list of items based on the date range selected.
I am looking to incorporate the following functionlity:
Have a button that says "Filter". No input.
User can click on that button which then opens the calendar showing 2 months - the current and next.
User can then select a date range.
The selected date range then becomes the label of the button showing the user what he or she selected.
Is this functionality possible? It breaks completely when I try to add the calendar on the button. And when I use the input to popup the calendar it only allows me to select a start date, then closes.
Here is what I am going for:
<button #dp ngModel (click)="d.toggle()" (ngModelChange)="onDateChange($event)" [displayMonths]="2" [dayTemplate]="t" ngbDatepicker #d="ngbDatepicker">
Click Me
</button>
<ng-template #t let-date="date" let-focused="focused">
<span class="custom-day"
[class.focused]="focused"
[class.range]="isFrom(date) || isTo(date) || isInside(date) || isHovered(date)"
[class.faded]="isHovered(date) || isInside(date)"
(mouseenter)="hoveredDate = date"
(mouseleave)="hoveredDate = null">
{{ date.day }}
</ng-template>
Thanks

Related

Instead of pick-list field how to create radio button in salesforce lightning component

I have created a page with lightening components as shown the below image, I want to change my pick-List field into radio button next to picklist option to choose the appropriate selection, can someone please help to create radio buttons instead of pickList filed
in the component I have used below code
<div class="slds-form-element">
<div class="slds-form-element__control">
<ui:inputSelect label="Race Type"
aura:id="Type"
class="slds-select"
labelClass="slds-form-element__label"
value="{!v.newRace.Race_Type__c}" />
</div>
Maybe something in line with this: (replace v.Name with attribute that contains the name of the race):
<aura:component>
<lightning:radioGroup name="radioGroup"
label="slds-form-element__label"
options="{! v.newRace.Race_Type__c }"
value="{! v.Name}"
type="radio"/>
</aura:component>

How to write xpath to get result for current active window?

I have same button like Save & Close on different tab in my application. If I write XPath like //button[contains(text(), 'Save')] it shows result for all button with 'Save' text present on different tab either active or inactive. Is there any way to get result for 'Save' button only for currently opened active tab?
These are HTML for 'Save' button for different places. I want to write one XPath which should work for all 'Save' button so that I can use it in a method. Wanted to know is there any way to get result for presently opened tab?
1)
<button class="btn ng-binding btn-primary" style="margin-right:5px;" ng-class="checkDeleteCrud()" ng-click="modalActionManager()" ng-disabled="disableSaveButton()" ng-hide="crudStatus==='V'" type="button" aria-hidden="false">Save
</button>
2)
<button class="btn ng-binding btn-primary" ng-class="checkDeleteCrud()" ng-click="modalActionManager()" ng-disabled="( notValidType() || locksavebutton || !createStatisticsForm.$dirty ) && saveButtonText=='Save' " ng-hide="crudStatus==='V'" type="button" aria-hidden="false">
Save
</button>
3)
<button class="btn ng-binding btn-primary" style="margin-right:5px;" ng-class="checkDeleteCrud()" ng-click="modalActionManager()" ng-disabled="disableSaveButton()" ng-hide="crudStatus==='V'" type="button" aria-hidden="false">Save
</button>
If you are looking for something generic for visible button why not simply go with CSS Selector like :
button[ng-disabled*=' ']
If I explain currently all your disabled elements have ng-disabled value equal to disableSaveButton() but the active element doesn't have this function but contains data with spaces so I will look in any spaces within button ng-disabled data simple.
Hope this helped.
First look for the active tab, for this you need to know how the active tab in the Dom differs from non-active tabs. Then look in this element for a button with the text "Save". Use a dot as the first character in your XPath expression.
Let say webelement "tab" is the active tab then you can find the button as follows (C# code):
tab.FindElement(ByXPath(".//button[contains(text(),'Save')]")

How to select a specific value from drop down list in webdriver

I am new to selenium and need help to figure out how to select a specific value from drop down list. Scenario is that when I click on the arrow it gives a list to select from and when I select any of the value, another filed opens up to enter value in it. So please tell me how to select value from the list by clicking on it.
Here is the HTML:
div class="custom-select"
<select class="ng-pristine ng-untouched ng-invalid ng-invalid-required" required="" ng-class="{ 'ng-fieldEmptyOnCreate' : (profileAdminTab.modalrole.$dirty || submitted) && profileAdminTab.modalrole.$error.required }" ng-options="item.Role for item in RolesData | filter: {IsSecurityRole: true} | orderBy: 'RolePriority':false" ng-change="SetAllowedPermission()" ng-model="RolesData.selectedRole" name="modalrole">
<span class="error ng-binding ng-hide" ng-show="(profileAdminTab.modalrole.$dirty || submitted) && profileAdminTab.modalrole.$error.required">Roles are required</span>
/div
/div
Thanks
The quickest way would be to use Selenium IDE to record user actions and then interrogate the html generated to see what the elements and drop down selectable items are called.

Clicking particular element in a drop down list

Can you please help me click on an item in a drop down list. I have a class called prompt-wrapper which contains user names. I want to click a particular user.
In the example below I have only one user but the list can have multiple users. Here I want to click on "Janice Hunt".
<div class="prompt-wrapper" data-reactid=".0.0.3.0.$message-panel.2.2">
<div class="prompt-item selected hover" data-reactid=".0.0.3.0.$message-panel.2.2.1:$user_950413">
<div class="prompt-item-avatar" data-reactid=".0.0.3.0.$message-panel.2.2.1:$user_950413.0">
<img src="/bundles/neighbourlyregistration/img/avatar.png" data-reactid=".0.0.3.0.$message-panel.2.2.1:$user_950413.0.0">
</div>
<span class="prompt-item-name" data-reactid=".0.0.3.0.$message-panel.2.2.1:$user_950413.1"><strong>Janice</strong> Hunt</span>
<span class="prompt-item-address" data-reactid=".0.0.3.0.$message-panel.2.2.1:$user_950413.2">
<span class="glyph icon glyphicon-marker" data-reactid=".0.0.3.0.$message-panel.2.2.1:$user_950413.2.0"></span>
<span data-reactid=".0.0.3.0.$message-panel.2.2.1:$user_950413.2.1"> </span><span data-reactid=".0.0.3.0.$message-panel.2.2.1:$user_950413.2.2">Suburb</span></span>
</div>
</div>
You can locate the desired item in the dropdown by XPath:
//span[#class="prompt-item-name" and strong = "Janice" and contains(., "Hunt")]
Don't forget to click the dropdown to open it up before selecting an item.
If you need to click on a particular value in drop down use the below code, if there are many values in the drop down field.
//get the drop down field first via id, name, className, cssSelector etc...
WebElement propertySelectBox = browser.findElement(By.className("txtfld"));
//Use 'Select' statement
Select propertyComboBox = new Select(propertySelectBox);
// 4 means 5th Element
propertyComboBox.selectByIndex(4);

Modal: using modal within elements that were loaded via AJAX after document.load()

What happened: I have a page where user has to click on a button and selection is displayed in modal. When they clicked on what ever they wanted div element on the page is updated, via AJAX, which shows what they have selected and has an option "view item".
I have defined that "view item" should open up another modal view which will have all the information on the item, and now, referring to the above paragraph, rather then opening modal view user is being transferred to that page?
Question:
Is their a walk around for modal to be activated on the elements that were loaded after document load stage?
Example code: On initial load user is presented with following code, at this example item was set prior to load:
<div id="dynamic-area">
Item 1
view selection
</div>
<input type="radio" name="selection" id="selection" value="" data-toggle="modal" data-remote="/selection/search/1" />Change selection
When user have picked a different item after clicking on "change selection" #dynamic-area was fully updated with a data that was fetched via AJAX on the selected item.
So lets say, if user have picked item 3, we would have code below:
<div id="dynamic-area">
Item 3
view selection
</div>
<input type="radio" name="selection" id="selection" value="" data-toggle="modal" data-remote="/selection/search/1" />Change selection
Now if user to click on the "view selection", user is being to the page 'selection/view/3' when user should see modal.
After extending this function action worked as it should