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

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

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')]

Ionic 4 - Select not showing selected value set in controller

Problem:
I have an ion-select and in the controller when the user does something, I populate the ion-select with 1 value and make that value the selected value. The ion-select does not show that the value has been selected, but the [(ngModel)] has the correct value. When I open the ion-select it shows the value in the list and it is selected, when selecting the value in the list again it goes over the ion-select label.
How can I populate the ion-select with a value and make the populated value the selected value so that it shows on the ion-select as a selected item?
Screenshots:
The Make has value of CHEVROLET but it does not show as selected by ion-select:
When tapping on ion-select, it shows the CHEVROLET as selected and CHEVROLET goes over the Make label:
HTML:
<ion-item>
<ion-label position="floating">
<span class="required">* </span>Make
</ion-label>
<ion-select [interfaceOptions]="global.compactAlertOptions" id="make" [(ngModel)]="global.valuation.vehicle.make" name="make" #makeRef="ngModel" required>
<ion-select-option *ngFor="let make of makes">{{make}}</ion-select-option>
</ion-select>
</ion-item>
<ion-label *ngIf="makeRef.touched && makeRef.invalid && makeRef.errors.required" class="error">Make is required</ion-label>
Controller:
Modal Controller (the Make gets set in a popup modal):
this.global.valuation.vehicle.make = this.vehicleDetails.VehicleMake;
Populate the ion-select options in parent controller:
this.makes = [this.global.valuation.vehicle.make];
This generally happens when the value in ngModel is set before <ion-select-option> options are loaded on the DOM.
You will have to explicitly delay setting the value to ngModel until the <ion-select> and options are loaded on the DOM.
You can achieve it by adding a setTimeout in your component file and assign the ngModel value in the callback of setTimeout.
It seems to me that this has to do with some custom css that you are using on the template. Since when you use floating for a select is exactly the same as when you use stacked, Since the select is going to expand on the ion-item anyway. This floating works best with ion-input.
In your case, if the option was not selected, the select should be empty and the label above it. but it is on the item furthermore on the baseline of the select. When you select the option it will show in the baseline on the select left aligned.
like this:
If you remove the floating you will see what I mean.
it should show like this:
It will be easier to understand the issue if you just provide the CSS bits that are messing with the alignment of the elements.
My guess is that you have some styles that only reduce the ion-item and don't deal with alignment and positioning of the inner elements.

Geb: How to add new attribute and its value

I have an input element where I need to set one extra attribute and its value.
<input autocomplete="off" id="to_input" name="to" class="form-control arrival ui-autocomplete-input" placeholder="To" data-input-component="searchCondition" data-input-support="suggest" type="text">
I need to add the below attribute:
How can I do this in Geb?
To say a little more details, when I enter TPE in the input text box, some dropdown items appears and when I select one of them like
"Taipei, XXX.. (TPE)"
Than the new attributes are set automatically same as the picture above.
The only way to do it, is using JavaScript executor:
browser.driver.executeScript("your script")
And script using jquery will look like:
$('jquery-selector').attr('attribute-name', 'attribute-value');
Of course make sure to fill in your data in quotes!

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.

CheckMultiSelect - Dojo

<input data-dojo-type="dijit.form.FilteringSelect"
data-dojo-props="name: 'jobSelect', store:Practiv.Q.jobStore, searchAttr:'JobNumber'"
id="jobIdSelect" />
Currently the above code displays a drop down with items that can be selected. I currently want to add a checkbox to the drop down list. I have replaced it with the code below.
<select data-dojo-type="dojox.form.CheckedMultiSelect"
data-dojo-props="name: 'jobSelect', store:Practiv.Q.jobStore, searchAttr:'JobNumber'"
id="jobIdSelect" ></select>
Unfortunately it doesnt work. Any suggestions?
instead of setting store in data-dojo-props set like this :-
<select data-dojo-type="dojox.form.CheckedMultiSelect" store="Practiv.Q.jobStore"
data-dojo-props="name: 'jobSelect', searchAttr:'JobNumber'"
id="jobIdSelect" ></select>
first you have ensure that your store is connected to CheckMultiSelect.