Submit dojo editor contents with form submission - dojo

Presently because of "onchange" the editor contents are submitted only if the contents of editor change. How do I make sure that the dojo editor contents are submitted everytime a form a submitted irrespective of whether a change has occurred or not?
Code snippet:
<td>
<input type="hidden" name="editorContent" id='editorContent' value="replaced by dijit.Editor content onsubmit" />
<div dojoType="dijit.Editor" id="content" onChange="dojo.byId('editorContent').value = this.getValue();" plugins="['foreColor','|','bold','italic','underline','|','createLink', 'unlink']" extraPlugins="['dijit._editor.plugins.AlwaysShowToolbar']">
</div>
</td>

You could write a simple onSubmit handler to do this, though the way you have the code structured, initializing the hidden field to the loaded value should accomplish the same thing.

Related

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

Upload file to hidden input using protractor and selenium

I've got a hidden file input field like this:
<input type="file" id="fileToUpload-1827" multiple="" onchange="angular.element(this).scope().setFiles(this)" data-upload-id="1827" class="hidden-uploader">
I'd like to be able to upload files to this. The normal way to do this in protractor would be to do:
ptor.findElement(protractor.By.css('.file-upload-form input')).sendKeys('/path/to/file')
But because the input element isn't visible, I get an error.
I tried:
ptor.driver.executeScript("return $('.file-upload-form input')[0].removeClass('hidden-uploader');").then(function () {
ptor.findElement(protractor.By.css('.file-upload-form input')).sendKeys('hello');
})
But got the error
UnknownError: $(...)[0].removeClass is not a function
It seems ridiculous to have to use executeScript to make an element visible so that I can upload a file, is there a better way? If not, how do I unhide the element?
The full html for the input form is:
<form class="file-upload-form ng-scope ng-pristine ng-valid" ng-if="ajaxUploadSupported">
<strong>Drag files here to upload</strong> or
<label for="fileToUpload-1953">
<div class="btn btn-info select-file-btn">
Click to Select
</div>
</label>
<div>
<input type="file" id="fileToUpload-1953" multiple="" onchange="angular.element(this).scope().setFiles(this)" data-upload-id="1953" class="hidden-uploader">
</div>
</form>
The only way I could find to do this in the end was to use javascript to make the input element visible.
So I have a function unhideFileInputs:
var unhideFileInputs = function () {
var makeInputVisible = function () {
$('input[type="file"]').removeClass('hidden-uploader');
};
ptor.driver.executeScript(makeInputVisible);
}
This contains the function 'makeInputVisible' which is executed in the browser when I call ptor.driver.executeScript(makeInputVisible). Because I know my page contains jQuery I can use the jQuery removeClass method to unhide my file input element.
To see more on how to execute javascript in the browser using webdriver, see the answer to this question (although the answer uses executeAsyncScript rather than executeScript).
To add on user2355213s answer for the more current releases of protractor. ptor is obsolote and instead browser should be used. Also, executeScript() expects a string as parameter. So I ended up using
browser.executeScript('$(\'input[type="file"]\').attr("style", "");');
as my visibility setting was directly applied to the element. Of course, you can also use
browser.executeScript('$(\'input[type="file"]\').removeClass("hidden-uploader");');
depending on your HTML/CSS.

MS Visual Web Developer Double click VB.NET

MS Visual Web Developer 2010-VB.Net
When button is double clicked ,i want to show some controls.How to add codes in double click event.
Thanks
Based on the fact that you're using Visual Studio Web Developer, I'll assume you're doing something with a browser. If you're not, comment on the answer and I'll delete it.
ASP.Net doesn't distinguish between single and double clicks. You'll have to use Javascript for this. To do what you're trying to accomplish, you'll have to make a client-side button whose ondblclick event calls the .click() function of the server-side button's rendered <input> element. Here's what I mean:
<asp:Button Id="Button" OnClick="Some_Method()" />
<!-- This renders to something like this: -->
<input type="submit" onclick="..." name="Button" id="Button" />
Knowing this (you can check this in your rendered document), you can do this:
<input type="button" ondblclick="document.getElementById('Button').click()" ... />
Of course, you probably only want one button visible. To do this, simply set Visible to false in the ASP.Net server control.
Again, this question could be for non-ASP.Net stuff, in which case this answer is worthless. If so, comment telling me so, and I'll delete the answer.
You can do this purely in client side.
Add client-side button that has "ondblclick" event to your ASPX/HTML page:
<button ondblclick="showControls()">Show Controls</button>
Add a DIV with display style set to none. Place your controls inside of that DIV:
<div id="myControls" style="display:none">
My<br>
Control<br>
are<br>
placed<br>
here<br>
</div>
Add client-side code that unhides that DIV:
<script>
function showControls(){
document.getElementById("myControls").style.display=""
}
</script>
Live demo: http://jsfiddle.net/5haxS/

ModX Eform: Captcha not generating image

I am trying to get CAPTCHA working on the eForm plugin. I have added the input form field:
<label for="cfCaptcha">Captcha:<br />
<img src="[+verimageurl+]" alt="verification code"><br />
<input id="vericode" name="vericode" class="text" type="text">
and I have added
&vericode=`1`
to the eForm call.
and have added the Template Variable [+verimageurl+] to my template.
However, when I preview the form all I see in the image area is <img src="" alt="verification code">
Would anyone know what I am doing wrong?
Did you get this fixed?
Check that you ended the label code. Run it through w3c code checker too.
A few times I have left a element un-closed and it breaks the whole thing.

Paste a text to textarea in browser control in Vb.Net

How can I paste a text to the text area within a form in the browser control?
I think how i have selected is correct
browser1.Document.Forms.GetElementsByName("editform").GetElementsByName("input")
UPDATE:Here is the Html
....
<form name="editform">
<textarea name="input">
</textarea>
</form>
...
Here is an example of how it can be done based on the HTML you've provided. You must first add a reference to MSHTML via the Microsoft.mshtml. Also, I would recommed adding an id attribute to the text area then you can get to it much easier. Something along these lines.
<form name="editform">
<textarea id="myTextArea" name="input">
</textarea>
</form>
Then you can set the value property of the text area.
Dim textArea As HTMLTextAreaElement
textArea = WebBrowser1.Document.GetElementById("myTextArea").DomElement
textArea.value = "Hello World!"
Figured out it's not possible due to security reasons.