autocomplete input show value even value is empty - input

I have input with autocomplete.
<input type="text" class="form-control input-sm isFieldValueEmpty tooltip"
style="width:779px;" id="searchK" name="keywords" value=''>
Everything works good, but I set value of autocomplete and after that add value from autocomplete to hidden input (user can choose many value from autocomplete). But when I add this value and try to set empty value of autocomplete input:
$("#searchK").attr("value","");
In input field still have text, but value od this input is empty (checking by firebug).
Any idea how delete this text?
I found solution
$(this).val('');
return false;
And input is clear.

Don't use attr() to change the value, use val()
$("#searchK").val("");

Related

How to access Value from hidden input tag in cypress

This is a dropdown and by default value is "False".
The dropdown value changes in hidden input tag only after selecting true.
<div class="dx-dropdowneditor-input-wrapper dx-selectbox-container" xpath="1">
<input type="hidden" value="False">.
How do I assert this element should contain "False" by default
cy.get('.dx-dropdowneditor-input-wrapper.dx-selectbox-container')
.should('have.value','False')
But it is not accessing this value.
Expecting to be able to assert that by default the value is "False".
You would need to add the input element tag into the selector
cy.get('.dx-dropdowneditor-input-wrapper.dx-selectbox-container input')
.should('have.value','False')
or "find" the input like this
cy.get('.dx-dropdowneditor-input-wrapper.dx-selectbox-container')
.find('input[type="hidden"]')
.should('have.value','False')

How to validate Check box if xpaths are same in case of selected and unselected

M unable to validate checkbox, if it's selected or not
because both the HTML are same
I tried isSelected(), but it's not working
Below is the HTML code for both selected and unselected
1) Selected
<label class="c-account-access-panel__checkbox " for="23336" data-js-checkbox-label="">
<input id="23336" class="c-account-access-panel__checkbox-input" type="checkbox"
data-label-for-value-missing="Please select at least one account from the options below" data-form-field-validation-on-grid=""
required="" checked="" data-js-checkbox="" value="DE29973399" name="payer"/>
<div class="c-account-access-panel__checkbox-symbol"/>
2) Unselected
<label class="c-account-access-panel__checkbox " for="23336" data-js-checkbox-label="">
<input id="23336" class="c-account-access-panel__checkbox-input" type="checkbox"
data-label-for-value-missing="Please select at least one account from the options below" data-form-field-validation-on-grid=""
required="" checked="" data-js-checkbox="" value="DE29973399" name="payer"/>
<div class="c-account-access-panel__checkbox-symbol"/>
Thanks in advance!
As per the Java Docs isSelected() method determines whether the element is selected or not. This operation only applies to <input> elements such as checkboxes, options within a <select> tag and radio buttons.
To validate if the desired checkbox is selected or not you can use the following code block:
boolean checkboxSelected = driver.findElement(By.xpath("//input[#class='c-account-access-panel__checkbox-input' and #name='payer']")).isSelected();
If isSelected() is not working for you. Then , you can use JavascriptExecutor to do your task. Following JS statements shall let you know the state of target checkbox.
document.getElementById("23336").click();
document.getElementById("23336").checked;
The checked method returns true or false depending on the checkbox state.
You can validate using getAttributemethod.
First select the webElement using any of the unique locator,
WebElement checkbox=driver.findElement(By.xpath(".//input[#type='checkbox']"));
If the checkbox is selected, then checkbox.getAttribute("checked")will give the result as true else, it will give the result as null. So, you can add the condition using checkbox.getAttribute("checked")
Use xpath expression like: (//div [#id='23336')[1] or (//div [#id='23336')[2] to make them into unique element then do .isselected ()

How to get value of input field on focus vuejs

I have a input field
<input #focus="showTimeAvailabilityModal(this)" class="form-control" v-model="date1" placeholder="First Date & Time Preference"/>
I called a function showTimeAvailabilityModal on focus of that input field.
I need to get value of input field in this function. How can I do this in simplest way?
You can do this.
showTimeAvailabilityModal(){
var date =this.date1;
}
or try this
#focus="showTimeAvailabilityModal(date1)"

vb.net html input placeholder

HTML Code
<input placeholder="0000000000" type="text" name="msisdn" id="msisdn">
i've tried innertext by this code :
WebBrowser1.Document.GetElementById("msisdn").InnerText = TextBox1.Text
but it change the placeholder value not the inner text of textbox
i want to change the exact text value of textbox not the placeholder value
Try this:
WebBrowser1.Document.GetElementById("msisdn").SetAttribute("value", TextBox1.Text)
You're looking for the .value property.
innerText is for content; <input> elements don't have content.

TestStack.Seleno TickCheckbox not working

I have 2 forms that I am testing using TestStack.Seleno. Both forms have a checkbox that is mandatory. The first form has (including the checkbox) 5 fields. I can use TestStack.Seleno to create a passing test with valid data. I set the checkbox like this:
Input.TickCheckbox(f=>f.Accept,form.Accept);
On my other form which has 10 or so fields, when I try to set the checkbox to be ticked (using the same code) nothing happens. However when I try
var acceptCheckBox = Find.Element(By.Name("Accept"),new TimeSpan(0,0,0,50));
if (form.Accept)
{
acceptCheckBox.Click();
}
I get error "Element is not currently visible and so may not be interacted with"
Element is clearly visible and is not injected in using javascript.
I am using latest version of TestStack.Seleno from github.
Any ideas?
So I have managed to figure out what the issue is and have a work around, however I cannot explain why it works on the other form. The mandatory Accept field has html generated by mvc that looks like
<div>
<input class="check-box" data-val="true" data-val-mustbetrue="The Accept our field is required" data-val-required="The Accept our field is required." id="Accept" name="Accept" type="checkbox" value="true"><input name="Accept" type="hidden" value="false">
<label for="Accept">
Accept our Please accept our Terms and Conditions
</label>
<span class="field-validation-valid" data-valmsg-for="Accept" data-valmsg-replace="true"></span>
</div>
So you have the checkbox and hidden field both with id Accept, I suspect in code seleno is picking up the hidden field and setting value, so I updated my code todo
var acceptCheckBox = Find.Element(By.CssSelector("#Accept.check-box"));
acceptCheckBox.Click();
Now everything works.
Ismail