WatiN and typing capital letters - watin

I'm trying to automate a password entry but the website in question does not allow you to type your password with the caps lock key on. WatiN appears to use the caps lock key in order to type capital letters thus not allow this to work.
Does anyone know a workaround or a way to force WatiN to use the shift key?

You could write your own extension to the TextField class like this...
public static class WatinHelper
{
public static void TypeTextFast(this TextField textField, string text)
{
textField.SetAttributeValue("value", text);
}
}
and then use TypeTextFast instead of TypeText. This would furthermore improve typing speed considerably (particularly in IE) when running the WatiN test. See this for further details.

The TextField class has the Value property you can use to set text of the TextBox directly, without mimicking a manual input, like the TypeText() method.
As a side note, because the value is set behind the scene, it may not raise an event that the value has change, which could be necessary if action append as you type. The TypeText() was taking care of that for you. In those case you can use the Change() method after setting the Value.

It has been a while since I created anything with WatiN, but you can assign the text directly with something like this:
TextBox.Text = "PaSsWoRd";
I logged into a website without any problems using the above.

Related

how to call SetExtendedUI on CMFCToolBarFontComboBox

I am creating a MFC application based on example: https://github.com/microsoft/VCSamples/tree/master/VC2010Samples/MFC/Visual%20C%2B%2B%202008%20Feature%20Pack/WordPad
now i want to change the way to expand font name drop list in toolbar from DOWN key to F4. It seems i need to get the combobox and call SetExtenedUI(FALSE) on it, but i dont know where to do it.
To change the extended UI flag on a CComboBox, you call its CComboBox::SetExtendedUI member. When you have a CMFCToolBarFontComboBox you need to get to its combo box first. Since it inherits from CMFCToolBarComboBoxButton you can use its CMFCToolBarComboBoxButton::GetComboBox member to get a CComboBox*.
CMFCToolBarFontComboBox* pFontButton = ...;
CComboBox* pComboBox = pFontButton->GetComboBox();
pComboBox->SetExtendedUI(FALSE);
finally i switched to CComboBoxEx which works fine

How do you place default message in the semantic react ui search?

https://react.semantic-ui.com/modules/search
Below is images of how the semantic react ui search widget looks like. In the second image, I was wondering how you can put a prompt message to indicate to the user a message on what the search bar is meant for. In this case, it's "search". When the user types in, it erases the Search and starts reflecting what the user is typing. I thought it would be defaultValue, but it seems that you can't have value and defaultValue set at the same time. I still want to be able to read what the set value is when the user types into the box.
Thanks,
Derek
You can use defaultValue as initial value in component, no problem.
Then read the user input value in event (onBlur for instance) like this:
onBlur(e) {
e.preventDefault();
console.log(e.target.name, e.target.value);
}
If you want to read value each new character pressed you can use in onSearchChange event:
onSearchChange(e) {
e.preventDefault();
console.log(e.target.name, e.target.value);
}
EDIT: included accepted answer in comment below:
Worked:
placeholder={"text"}
for Semantic React UI Search

For SafeHtml, Do we need to sanitize the "link" in <img src=link> tag, GWT?

I got a textbox that allows users to put image link (ex: http://abc.test.gif) & another textbox that allows user to put Alternate text (ex: "This is test.gif"), & a submit button.
When a user clicks on submit buton, the program will generate <img src="http://abc.test.gif" alt="This is test.gif"> this string & store it into DB for later use.
My question is: do i need to sanitize the imagelink "http://abc.test.gif" & the text in alt tag "This is test.gif"
For example, do i need to use UriUtils.isSafeUri("http://abc.test.gif"); & SafeHtmlUtils.fromString("This is test.gif"
You are deliberately allowing the user to input anything he want that will go into the src and the alt attributes of the img tag. This is indeed open to any kind of XSS attack. Have a look here for some examples that still work in recent browsers.
Also, you are storing the string in your DB for later use (guessing), so the attack may occur at later time, when you will use such string to create a node in the DOM, with even more unpredictable results.
One solution could be to store only the URL and the alternative string in the database (with a proper input validation, if any), and generate the safe img snippet right when you need it, with a simple template like the following (or programmatically using SafeHtmlBuilder).
public interface Template extends SafeHtmlTemplates {
#Template("<img src=\"{0}\" alt=\"{1}\"/>")
SafeHtml img(SafeUri uri, SafeHtml alternativeText);
}
To be used like:
template.img(
UriUtils.fromString(yourValidatedDbUrl),
SafeHtmlUtils.fromString(yourValidatedAlternativeText));
This way you:
validate the user input;
store only the validated values (as-are);
generate the img snippet in a safe way only when really needed.

How may I prevent the Designer changing control member modifiers to private?

When in the Designer I change a property of a DataGridViewColumn on which I previously manually changed the modifier to public in the .Designer.cs file, the modifier gets reverted to private.
Is there any way to prevent this?
I would recommend not changing the designer.
If you really need to have your controls public, I would recommend adding a property to expose them in your code file (not the designer file):
public TextBox MyTextBox { get { return this.textBox1; } }
This will provide public access to the designer generated types without worry of the designer overwriting your changes.
It also makes it much more clear, in the long run, since your public API is defined in your main code file, and not in a second, designer generated file.
That being said, in general, I'd avoid this. Instead of exposing the control itself, I would actually recommend exposing the data that you want to set. Take the text box above - If this text box was a title, I would expose that directly:
public string Title
{
get { return this.textBoxTitle.Text; }
set { this.textBoxTitle.Text = value; }
}

Cocoa-Bindings : Update NSObjectController manually?

In my little cocoa application I have bound the properties of a class to some text fields with help of a NSObjectController. The only problem I have so far: you always have to leave a text field before the NSObjectController updates the class with the current input.
This becomes a problem if the user doesn't leave a texfield and clicks on a Save/Submit Button right away. The class doesn't contain the current input. Always a bad thing.
I am looking for a way to avoid this. Like telling the NSObjectController to get the current input even if the user had exited the field. If this is possible I could put this command in the save-Method before saving and all would be fine.
Send a commitEditing message to your controller in the handler for the OK button. This will do what you're asking for. It's as simple as:
- (void)save:sender {
if (![self.myObjectController commitEditing]) {
// Handle error when object controller can't commit editing
}
// Other stuff
}
If you go to the text field's value binding and check the "Continuously Updates Value" option, that will cause the new value to be set on the model object each time the user changes it, i.e. once for each keystroke. That would ensure that the model had the correct value before closing the window, though it may be a bit overkill, depending on what the effects (if any) are of the value being set in your data model.

Resources