ngx-bootstrap typeahead - how to detect value not selected - ngx-bootstrap

I have implemented below typeahead from ngx-bootstrap
<input [(ngModel)]="selectedCountry" [typeaheadMinLength]="0"
(typeaheadOnSelect)="countrySelected()" [typeaheadOptionsLimit]="100"
[typeahead]="countryList" class="form-control" [typeaheadScrollable]="true"
[typeaheadItemTemplate]="customItemTemplate" placeholder="Select Country....">
Everything working fine.
But when user press backspace or delete value from input and leave it without selected any value, not able to reset "selectedCountry" model.
Please let me know how to do it.

Related

Xpath Changes regularly

I have an issue. When I select an xpath and run the test sometimes the first few times it works. After some time it fails, and when i go check the xpath again i discover that somethings in it has changed. This isn't a web application that is being updated constantly . What do you think the problem could be?
for example the name in the code changes regularly . Here it is turnOverAvailableInd1 later it may become turnOverAvailableInd2.
<td>Is turnover figure available?</td>
<td valign="baseline">
<input type="radio" name="turnOverAvailableInd1" value="Y" onclick="javascript:turnOverAvailableToggle(this);" id="turnOverAvailableInd1Yes">YES
<input type="radio" name="turnOverAvailableInd1" value="N" onclick="javascript:turnOverAvailableToggle(this);" id="turnOverAvailableInd1No">NO
</td>
This is how i select the radio button
Select Radio Button turnOverAvailableInd1 N
You can use the other locator like, ID, CSS Selector or different XPATH like below
//input[#id='turnOverAvailableInd1Yes'] // For YES radio button
//input[#id ='turnOverAvailableInd1No'] //For NO radio button
OR
You can use the Value like below
//input[#value='Y'] //For YES radio button
//input [#value= 'N'] //For NO radio button
OR
//*[contains(text()='YES')] //For YES radio button
//*[contains(text()='NO')] //For NO radio button
You can find more here
If I understand your question correctly, you want an xpath that can work whether then name is "turnOverAvailableInd" appended by some number. If so, the following xpaths could work:
//input[#value='Y' and contains(#name,'turnOverAvailableInd')]
//input[#value='N' and contains(#name,'turnOverAvailableInd')]

ionrangeslider: disable drag the slider. Only want to use for display

I am using ionrangeslider to display some temperature value. I like the way it displays.
I dont want the user to slide it. How can i disable the slider
I didnt find any option to diable dragging
this is the html and the js i am using
<input type="text" class="js-range-slider" name="my_range" value=""
data-min="40"
data-max="210"
data-from="115"
data-grid="true",
data-hide-min-max="true",
data-postfix="'F"
/>
$('.js-range-slider').ionRangeSlider()
It shows as
if you want to fix the values top/from, you have option:
to_fixed:true,//block the top
from_fixed:true//block the from

How auto refresh component when data updated from api, without page refresh

I’m trying to make component like a LIKE count,
so,
i have a object is name (LIST) which i get from api, in my LIST object have property total_like which default value is 0, when i click to like button i make post request to api and in api my total_like value rising to 1 and 2 and etc.
in my view i’m displaying the like count with {{item.total_like}} everything work well to this point.
problem is item.total_like value updating only when i refresh the page, but i want to show new value of this property without refreshing page.
how can i figure out with it ?
regards
Maybe you can use the event modifiers to prevent page reloading, examples are...
<button type="submit" v-on:click.prevent="addLike" >
<button type="submit" v-on:submit.prevent="addLike">
or if you want to use the shorthand
<button type="submit" #click.prevent="addLike" >
<button type="submit" #submit.prevent="addLike">
Hope this helps.

Checkbox id keeps changing in webpage causing selenium script to fail

I am trying to automate a click on a certain checkbox. However after every run the checkbox id changes and script fails to find the element. Is there an alternate way of writing an xpath
<span id="field_key$0993573c-83b4-30d4-9139-44e44b496d0f$1food_contamination-checkbox" class="v-checkbox v-widget" ca-help-field-id="undefined">
<input id="gwt-uid-193" type="checkbox" value="on" tabindex="0" checked=""/>
<label for="gwt-uid-193"/>
</span>
xpath I used was this:
//*[#id='gwt-uid-193']
If the parent <span> id is fixed you can use it and go one level down to the checkbox
driver.findElement(By.cssSelector("#field_key$0993573c-83b4-30d4-9139-44e44b496d0f$1food_contamination-checkbox > input"));
Or use the parent class
driver.findElement(By.cssSelector(".checkbox > input"));
And if you have only one checkbox you can use the type attribute
driver.findElement(By.cssSelector("[type='checkbox']"));
I found a solution myself. We can use xpath based on the position of the checkbox, i.e.:
// input[#type='checkbox'])[position()=3]
This can be used for radio buttons as well. Replace checkbox with radio.

placeholder input field not showing value?

I have an input box with placeholder.and I am setting the value in this field via Session variable in php.
This is the code which I have written :
<input type="text" value=<?=$_SESSION['no_of_persons']?> name="no_of_persons" id="no_of_persons" placeholder="No. of Person(s)" maxlength="3" />
and when I run this in firefox and watching the code in Firebug this following code is coming :
<input id="no_of_persons" type="text" maxlength="3" placeholder="No. of Person(s)" name="no_of_persons" value="7">
Problem is I am not able to see the value in textfield in the web page.
I go to firebug and edit html in firebug. What I do is when I press an space key at the end of input tag i.e after value="7" then the value 7 becomes visible on web page.
I am not getting why the browser automatically changing the sequence of attributes of input tag and also I already had closed input tag then why the browser not closing it.
I tried it in other browser also like safari,chrome but not working.
Please help me to get rid off this problem.
Thanks in advance!!! :)