How to Pass Multiple Values into TextField using Watin - watin

I'm using WatiN for web application testing. There is a field called enter choices where i need to add 3 values one after the another by pressing enter key i.e., add 1st value then press enter key and Add 2nd value press enter key, so please suggest me how to make this work using WatiN.
thankingyou

Here is another answer for the problem. When i passed enter key there it was giving a "Keyword delimiter is missing" error so instead i passe "\r\n" it worked fine.
WatiN.Core.IE ie = new WatiN.Core.IE():
TextField txtChoices = ie.TextField(Find.ById("ctl00_ContentPlaceHolder1_TxtChoices"));
txtChoices.TypeText("NotBad");
System.Windows.Forms.SendKeys.SendWait("\r\n");
txtChoices.AppendText("VeryGood");
System.Windows.Forms.SendKeys.SendWait("\r\n");
txtChoices.AppendText("Awesome");

The above method which jose has suggested, i made little changes to the code it worked for me. Jus replace TypeText by AppendText for entering the second value.
WatiN.Core.IE ie = new WatiN.Core.IE();
TextField txtChoices =
ie.TextField(Find.ById("ctl00_ContentPlaceHolder1_TxtChoices"));
txtChoices.TypeText("NotBad");
System.Windows.Forms.SendKeys.SendWait("{ENTER}");
txtChoices.AppendText("VeryGood");

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 to Auotmate Combo box for makemytrip as I am able to insert the value but once the focus is moved value is erased from the combobox

How to Auotmate Combo box for makemytrip as I am able to insert the value but once the focus is moved value is erased from the combobox
Try use Click first on that WebEdit (or maybe WebElement) object. Then, use SendKeys method to insert desired value. One potential issue here is that the value may still disappear even you use SendKeys, if so, try to send the string one by one. Google has lots of sample codes about SendKeys and sending string one character by one character.
If it's a WebEdit object, you might find it works best if you use the WebEdit("whateveritscalled").Type myDestinationString operation rather than Set or SendKeys.
Try the following, I am setting the values using the Elementid,it should work-
Browser("MakeMyTrip, India's No").Page("MakeMyTrip, India's No").Object.getElementById("from_typeahead1").value = "New Delhi, India (DEL)"
Browser("MakeMyTrip, India's No").Page("MakeMyTrip, India's No").Object.getElementById("to_typeahead1").value = "Mumbai, India (BOM)"

Searching on pressing enter button using selenium not working with Firefox

I have the below code. What I actually want to do is enter a string in text field and click on enter. Then search results should be displayed.
But here on 'element.sendKeys(Keys.ENTER);' application logs out. I checked with URLs. URLs should be same after searching.But it changes here.
This code works for Chrome and IE. Issue only with Firefox only.I checked the element type to confirm the clicking. It was text box only.
public static void pressEnterKey(WebDriver driver,WebElement element){
System.out.println("Current URL1" + driver.getCurrentUrl());
WebElementType elementType = WebElementHelper.findElementType(element);
System.out.println("Element Type = " + elementType);
element.sendKeys(Keys.ENTER);
System.out.println("Current URL2" + driver.getCurrentUrl());
}
There is a bug report regarding this issue, it seems to be specific with .NET and FireFox.
See here:
https://code.google.com/p/selenium/issues/detail?id=2079
The result would be to use
element.sendKeys(Keys.Return);
If the sole purpose is to click on the "Enter" button, instead of sending "Enter" keys why not click on the respective element.
Just replace the code element.sendKeys(Keys.ENTER); in your code above with either of the below code(s):
element.click();
OR
element.submit();
On another note, as per the definition, sendKeys method is used to type into an element. And, I am pretty sure you can't type into a button. :)

How to open and handle richtext editor in javascript in sitecore 6.5?

I've been working on a custom field, which contains a list.
I have to be able to edit the selected item on the list in a richtext editor. (this is the only missing part).
I've read the topic on opening from c# code Opening Rich Text Editor in custom field of Sitecore Content Editor .
This works nice for the "add" button, since i have to open the RTE empty(with default text...), but not for the Edit button.
My aproaches are:
Somehow in the Edit button's message field list:edit(id=$Target) pass the selected index (like list:edit(id=$Target,index=$SelectedIndex), but i don't know how to populate $SelectedIndex
Somehow in the overridden HandleMessage method get the list's selected index. I'm able to get the selected value Sitecore.Context.ClientPage.ClientRequest.Form[ID of list], but thats alone not much of a help, since i won't be able to decide which one to edit if two listitem equals.
Do the richtext editor opening and handling fully in javascript. As i saw at some script in content editor, i tried to do that, but i can't understand it clearly:
richtext editor url:
var page = "/sitecore/shell/Controls/Rich Text Editor/EditorPage.aspx";
some params :
var params = "?da=core&id&ed=" + id + "&vs=1&la=en&fld=" + id + "&so&di=0&hdl=H14074466&us=sitecore%5cadmin&mo";
and the part where i'm not sure:
var result = scForm.browser.showModalDialog(page + params, new Array(window), "dialogHeight:650px; dialogWidth:900px;");
This way the RTE opens as expected (i guess i could get the selected index from javascript and pass it as a parameter later). However when i click ok, i get exception from EditorPage.js saveRichText function: Cannot read property 'ownerDocument' of null. Am i missing some parameter?
Either of the three aproaches is fine for me(also i'm open for new better ones) as soon as i'm able to do it.
Thanks in advance!
Tamas
I was able to enter some javascript into the message:
list:Edit(id=$Target,index='+document.getElementById(ID of the select using $Target ).selectedIndex+')
this way i got the index in HandleMessage.
I'm waiting for better solutions now.

ui tab select using variable

I am having problems when trying to change a tab
The code below is working
$('#tabs').tabs('select', 1);
WORKING FINE
The code below
var nextTab=$('#nextTab').val();
$('#tabs').tabs('select', nextTab);
IS NOT WORKING
The nextTab variable is a valid tab index
What am I missing?
Are you sure nextTab holds a valid tab index? If yes, don't know if this makes a difference, but try converting it to a Number:
var nextTab = Number($('#nextTab').val());

Resources