I have
Watin.Core.teaxfield my date = x.textfield(find.byid("whatever"))
My date.value=2014-06-06"....this will set the value
My question is how can I select the value from a label or combo box that is is my windows form .thanks
For a combobox, you can select a value using something such as:
SelectList selectList = browser.SelectList(Find.ById("some_id"));
selectList.Option("some_option").Select();
To get a label value:
string value = browser.Label(Find.ById("some_id").Text;
Related
I am setting custom fields in a template via the DocuSign API from Salesforce. This works great for text fields. I am having trouble setting a checkbox field to checked. What is the value to send to a checkbox field so it shows as checked?
Here is an example of code to set text fields:
DocuSignAPI.TemplateReferenceFieldDataDataValue fd0 = new DocuSignAPI.TemplateReferenceFieldDataDataValue();
fd0.TabLabel = 'Lead Name';
fd0.Value = c.FirstName + ' ' + c.LastName;
I've tried setting the Value to true, checked, Checked, TRUE but none of these seem to work.
If you look at the official documentation of the CheckBox Tab, in order to your check box checked, you need to set the following property to true as my example in C# below :
Checkbox myCheckBox = new Checkbox
{
Selected = "true"
};
I have built a cascading LOV with Group and division fields (Combo box with list of values). When I select a value for Group and click on Search and Select dialog for Division field, the SearchAndSelect popup has both Group and Division fields as search criteria(as defined in my view criteria).
Now, is there a way to populate the Group value in the popup criteria, I know the where clause uses the already entered Group value but I want to display it to the user in the SearchAndSelect popup search region.
There is no declarative way of pre setting search field values in lov popup. Although it can be done by using a custom launchPopupListener for lov component. To know more about how to use lov popup listeners refer to Building Custom Lovs
Create a launchPopupListener method for your dependent lov.
<af:inputComboboxListOfValues id="inpClv2"
popupTitle="Search and Select: #{bindings.StateProvince.hints.label}"
value="#{bindings.StateProvince.inputValue}"
label="#{bindings.StateProvince.hints.label}"
model="#{bindings.StateProvince.listOfValuesModel}"
required="#{bindings.StateProvince.hints.mandatory}"
columns="#{bindings.StateProvince.hints.displayWidth}"
shortDesc="#{bindings.StateProvince.hints.tooltip}"
partialTriggers="inpClv1"
launchPopupListener="#{backingBeanScope.lovBean.stateLaunchPopupListener}">
</af:inputComboboxListOfValues>
In launchPopupListener set the value of search criteria attribute with the value from first lov.
public void stateLaunchPopupListener(LaunchPopupEvent launchPopupEvent)
{
UIXInputPopup lovComponent = (UIXInputPopup)launchPopupEvent.getSource();
ListOfValuesModel model = lovComponent.getModel();
if (model != null)
{
QueryDescriptor queryDesc = model.getQueryDescriptor();
/** Code to pre populate a Search and Select field**/
ConjunctionCriterion conCrit = queryDesc.getConjunctionCriterion();
List<Criterion> criterionList = conCrit.getCriterionList();
for (Criterion criterion: criterionList)
{
AttributeDescriptor attrDesc = ((AttributeCriterion) criterion).getAttribute();
if (attrDesc.getName().equalsIgnoreCase("CountryId"))
{
List values = ((AttributeCriterion) criterion).getValues();
values.set(0, "US"); //use the value from first lov
}
}
}
}
Assume I have this html code:
<select id="superior" size="1" name="superior">
<option value=""></option>
<option value="c.i.e.m.md.Division_1">DIVISION007</option>
<option selected="selected" value="c.i.e.m.md.Division_$$_javassist_162_119">MyDivision</option>
<option value="c.i.e.m.md.Division_121">MyDivision4</option>
<option value="c.i.e.m.md.Division_122">MyDivision5</option>
</select>
So this is a combo box with
id=superior
and currently value MyDivision is selected.
Using Selenium WebDriver I am trying to get the selected value, but no success.
I tried:
String option = this.ebtamTester.firefox.findElement(By.id(superiorId)).getText();
return option;
But this returns me all the values in the combobox.
Help please?
Edit:
WebElement comboBox = ebtamTester.firefox.findElement(By.id("superior"));
SelectElement selectedValue = new SelectElement(comboBox);
String wantedText = selectedValue.getValue();
This is written in C#, but it shouldn't be hard to transition it over to any other language you're using:
IWebElement comboBox = driver.FindElement(By.Id("superior"));
SelectElement selectedValue = new SelectElement(comboBox);
string wantedText = selectedValue.SelectedOption.Text;
SelectElement requires you to use OpenQA.Selenium.Support.UI, so at the top, type
using OpenQA.Selenium.Support.UI;
Edit:
I suppose for you, instead of 'driver' you would use
IWebElement comboBox = this.ebtamTester.firefox.FindElement(By.Id("superior"));
In Java, the following code should work nicely:
import org.openqa.selenium.support.ui.Select;
Select comboBox = new Select(driver.findElement(By.id("superior")));
String selectedComboValue = comboBox.getFirstSelectedOption().getText();
System.out.println("Selected combo value: " + selectedComboValue);
As MyDivision is selected currently, the above code would print "MyDivision"
selectedValue.SelectedOption.Text; will get you the text of the
selected item. Does anyone know how to get the selected value.
To get the selected value use
selectedValue.SelectedOption.GetAttribute("value");
To select an option based on the label:
Select select = new Select(driver.findElement(By.xpath("//path_to_drop_down")));
select.deselectAll();
select.selectByVisibleText("Value1");
To get the first selected value:
WebElement option = select.getFirstSelectedOption()
Using XPath in c#
string selectedValue=driver.FindElement(By.Id("superior")).FindElements(By.XPath("./option[#selected]"))[0].Text;
Based off #Micheal's answer this would be easier to work with following command:
string selectedValue = new SelectElement(driver.FindElement(By.Id("Year"))).SelectedOption.Text;
In ext js, when I have a combo, there is display value and value( which is sent to server). I do not need displayValue to send to server, but I need to capture it on the page and display an alert.
What is the eextjs method of doing this?
combo.getValue() will return the underlying value...and I do not see any combo.getDisplay()
EDIT: Just to clarify, I am looking to get the display value of the item that is selected by the user. I wish to show an alert on the onselect or on changeevent.
If you set the valueField property on the combo box to the value you wish to display in the alert that will work fine.
alert(combo.getValue());
If you want this value to be different from the value you submit to the server you will have to get the store from the combo box and find the corresponding record.
var store = combo.getStore();
var index = store.find('*YourFieldName*', combo.getValue());
if(index != -1)//the record has been found
{
var record = store.getAt(index);
//you can then do what you like with the record.
}
combo.getStore().getById(combo.getValue()).raw.displayAttribute //Ext 4.x,
//displayAttribute: displayField or displayed attrib in store data for the combo
We can retreive the underlying store, then use our value as a key to get the display value.
Something like this (I haven't tested it):
var displayValue = combo.getStore()[combo.getValue()]
We can get the combo box display value something like this...
getRawValue( ) : String
Returns the raw String value of the combo, without performing any normalization, conversion, or validation. Gets the current value of the input element if the field has been rendered, ignoring the value if it is the emptyText.
combo.getRawValue();
Let's assume that you have following in your combobox:
id: 'COMBOBOX_ID',
displayField: 'COMBOBOX_DIS_FIELD_NAME',
valueField: 'COMBOBOX_VAL_FIELD_NAME'
Then, you can do following:
var combo = Ext.getCmp('COMBOBOX_ID');
var comboStore = combo.getStore();
var index = comboStore.find('COMBOBOX_VAL_FIELD_NAME', combo.getValue());
if(index != -1)
{
var selectedItemDisplayValue = combo.getStore().getAt(index).get('COMBOBOX_DIS_FIELD_NAME');
}
I have two list that I load when my app starts. The first one loads a complete set of data from the database, the second one independently loads a set of associated data from file.
Each list is loaded into a BindingSource and set as the DataSource for their respective combobox. The data is loading just fine.
The issue is that I need to have the second comboBox only display the elements of its list that correspond with the selected value of the first list.
I have attempted to set the value members to the referential bit of data, but cant figure out how to get the comboBoxSettings to only show the the items whose EventID matches the selected item's EventID from the EventList comboBox.
//Event List comboBox
comboBoxEventList.DataSource = _eventSimPresenter.BindingSourceEventList;
comboBoxEventList.DisplayMember = "DisplayName";
comboBoxSettings.ValueMember = "EventID";
//Settings combobox
comboBoxSettings.DataSource = _eventSimPresenter.BindingSourceUserSettings;
if (_eventSimPresenter.BindingSourceUserSettings.Count > 0)
{
comboBoxSettings.DisplayMember = "EventName";
comboBoxSettings.ValueMember = "EventID";
}
thanks!
You can reate a method in _eventSimPresenter that return a BindingSourceUserSettings by eventId. When the 1st comboBox changes, take the selected eventId and update 2nd comboBox datasource:
...
comboBoxSettings.DataSource =
_eventSimPresenter.GetBindingSourceUserSettings(selectedEventId)
if (_eventSimPresenter.BindingSourceUserSettings.Count > 0)
{
comboBoxSettings.DisplayMember = "EventName";
comboBoxSettings.ValueMember = "EventID";
}
In other terms, the filtering should be applied to the datasource since it's not possible to do it via the comboBox.