A website I'm accessing utilizes a javascript code editor (code mirror) attached to a textarea box. This results in a div-style input box. How do I use casperjs to enter text into the box?
I've already tried entering text into the hidden textarea using sendkeys and it doesn't find the selector (because it is hidden).
Update:
this.evaluate(function(input) {
window.$('.CodeMirror')[0].CodeMirror.setValue(input);
}, intent_schema);
enters the text into the box as expected, but when I submit the form, the values aren't saved. Something isn't firing properly.
Thanks!
Related
Problem - Watch for active input boxes in a page and trigger events if specific words are entered into the input box
Steps
Click 'reply or reply all'
Input box becomes active
Enter |intro
|intro text gets replaced with long form version. The |intro is like a snippet or short code
Heres what I'm thinking
Query all input boxes on a page
Check for input with focus
Add event listener on input to check for keyup events
Conditional statement to check if string contains specific snippet/short code
If condition is met then replace snippet with long form text
What do you think of my approach to this functonality
Trying to submit an HTML form / clicking a button from this web page: https://www.vegvesen.no/kjoretoy/Eie+og+vedlikeholde/skilt/personlig-bilskilt/sok-om-personlig-bilskilt
I've tried to use both .submit() and .click() with no success
webView.evaluateJavaScript("document.getElementById('personlig-kjennemerke').click();", completionHandler: nil)
So what I try to do is to fill in the text field with "REGNR" I then try to click the orange button to submit the form and access the information I am looking for.
I am able to fill in the textfield by using:
webView.evaluateJavaScript("document.getElementById('tegnkombinasjon').val ue='\(plateNumber)'") { (value, error) in
}
Picture of the button I want to press and the text field I try to fill in
But since I'm not able to click the button programmatically I've tried to actually click it in a subview. The page then tells me I have to fill in the text field first even though I have programmatically.
So not only am I unable to click the button, but I'm also wondering how I can make the web page understand that the text field actually already contains text.
Try this:
webView.evaluateJavaScript("document.getElementsByName(\"sjekkreg\")[0].elements[2].click()")
Why by name? Because that form doesn't have an id.
Also I see your form has custom function to send that form:
pkCtrl.submit(mineFelt,sjekkreg)
I am working on an angular app which has a blog feature. The form input textarea takes in multiple paragraphs but displays them in one big paragraph. For example, if I enter
"this is para1.
this is para2."
it shows as
"this is para1. this is para 2."
I want to know if I can view the paragraphs separately, specially if I can input HTML code. For example , if I enter into the form input "para1 LINK", I want it to appear as "para1 LINK" where LINK is clickable.
You can not do this using Text Area. You can use WYSIWYG Text Editor where you can preserve html tags.
Check this angular plugin
http://textangular.com/
I am doing a task that display cafes around a location by using zipcode.
If we enter zipcode in a text field.it will get all cafes and display in a alert box.
Problem is if we enter zipcode and press enter cursor is presenting in background text field and if we enter any thing it is typed in that text field.
I think you want to remove the focus which is set to text box.
For that, you can have jquery blur() method.
To disable auto-focus on a particular element, pass the element id as below,
$(function(){
$('#someid').blur();
});
So I am building an input field with an auto-suggest box that suggests content based on the user's partial input into the field. Kinda like the tags box on stack. The auto-suggest box is absolutely positioned directly below the input field and only appears once the user begins to type text.
I want to make the box disappear when the input field is blurred, that is, when the user clicks anywhere else on the site. Normally, I would just use jquery's blur() function to hide the auto-suggest box. The problem is that if I do it this way, the user won't be able to select anything from the auto-suggest box because that would blur the input field and hide the auto-suggest box. I need to find a way to hide the auto suggest box if the user clicks anywhere except for the input field or the auto suggest box. Any ideas how I could set that up using jquery?
Imagine it is setup something like this:
<div id="auto_suggest">
<ul>
<li>Jane</li>
<li>john</li>
</ul>
</div>
<input type="text">
Use a timeout.
$("input, #auto_suggest, #auto_suggest a").blur(function() {
$('#auto_suggest').addClass('hiding');
setTimeout(function(){
$('#auto_suggest.hiding').hide();
},1000);
}).focus(function() {
$('#auto_suggest').removeClass('hiding').show();
});
$('#auto_suggest, #auto_suggest a').focus(function() {
$('#auto_suggest').removeClass('hiding').show();
});
Updated to work well with tabs or clicks:
http://jsfiddle.net/iambriansreed/vUeeT/