Unable to uncheck a checkbox within a combo box - ui-automation

I have a combo box which contains two List Items. Each list item consists of a checkbox and a text message.
Now, I am using a function which looks something like this to uncheck all the checkbox's within the combobox.
public ApplicationReports UnSelectAllCheckBox()
{
int i = 0;
ComboBox someVariable= Application.Library.GetFromWindow(Application.Configuration.LoginWindow.Title).OfType<ComboBox>("corresponding Automation Id");
foreach (ListItem casino in someVariable.Items)
{
someVariable.Item(i).UnCheck();
i++;
}
// someVariable.Item(0).UnCheck();
return this;
}
I am able to uncheck the second checkbox using this approach but not the first one. Unable to identify
what is the problem when it is working fine for the second list item. I am using the recently released version of
white framework. "someVariable" is not a problem. I checked its retrieving the correct combo box while
debugging.

Try this instead:
foreach (ListItem casino in someVariable.Items)
{
casino.UnCheck();
}
No need to use i and make your own loop iterator.

Related

Enterprise Architect: Hide only "top" labels of connectors programmatically

I want to hide the "top" part of all connector labels of a diagram. For this, I tried to set up a script, but it currently hides ALL labels (also the "bottom" labels which I want to preserve):
// Get a reference to the current diagram
var currentDiagram as EA.Diagram;
currentDiagram = Repository.GetCurrentDiagram();
if (currentDiagram != null)
{
for (var i = 0; i < currentDiagram.DiagramLinks.Count; i++)
{
var currentDiagramLink as EA.DiagramLink;
currentDiagramLink = currentDiagram.DiagramLinks.GetAt(i);
currentDiagramLink.Geometry = currentDiagramLink.Geometry
.replace(/HDN=0/g, "HDN=1")
.replace(/LLT=;/, "LLT=HDN=1;")
.replace(/LRT=;/, "LRT=HDN=1;");
if (!currentDiagramLink.Update())
{
Session.Output(currentDiagramLink.GetLastError());
}
}
}
When I hide only the top labels manually (context menu of a connector/Visibility/Set Label Visibility), the Geometry property of the DiagramLinks remains unchanged, so I guess the detailed label visibility information must be contained somewhere else in the model.
Does anyone know how to change my script?
Thanks in advance!
EDIT:
The dialog for editing the detailed label visibility looks as follows:
My goal is unchecking the "top label" checkboxes programmatically.
In the Geometry attribute you will find a partial string like
LLT=CX=36:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=1:DIR=0:ROT=0;
So in between LLT and the next semi-colon you need to locate the HDN=0 and replace that with HDN=1. A simple global change like above wont work. You need a wild card like in the regex LLT=([^;]+); to work correctly.

How to use selenium webdriver to select an option of Bootstrap select dropdown menu?

I've to select a country from dropdown of https://www.parcelhero.com but when I use the below code for it, sometimes it works sometimes not, giving error of Element not found(xpath("//*[#id='dvQuoteFrom']/div/button"))
driver.findElement(By.xpath("//*[#id='dvQuoteFrom']/div/button")).click();
Thread.sleep(4000);
WebElement txt = driver.findElement(By.xpath("html/body/div[14]/div/div/input"));
txt.sendKeys("Great Britain");
List <WebElement> InnerDropdown1 =driver.findElements(By.xpath("//*[#class='active']"));
for(WebElement option1 : InnerDropdown1)
{ System.out.println(option1.getText());
if(option1.getText().contains("Great Britain")) {
option1.click();
break;
}
}
When I used
WebElement txt = driver.findElement(By.className("bs-searchbox")); then also I got the uable to find element error.
Please help me to select a country of my choice from the country dropdown?
Try doing this. I've changed a few of your locators and tested this on the page you mentioned.
public void foo() {
driver.get("https://www.parcelhero.com/");
//This will be your dropdown button. This needs to be clicked first.
driver.findElement(By.xpath("//button[contains(#data-id,'ConsignorAddressCountryId')]")).click();
//These are your input boxes. I found 3 input boxes on the same page having the same identifiers. We dont want to rely on using index based xpath so here we'll get all instances of input boxes.
List<WebElement> elems = driver.findElements(By.xpath("//*[contains(#class,'bs-searchbox')]//input"));
for (WebElement elem : elems) {
//Here we check if the input box is visible. If I'm not mistaken, there will only be 1 visible input box at a time because you have to click on the dropdown button first.
if (elem.isDisplayed()) {
//If visible, just enter your country of choice
elem.sendKeys("American Samoa");
//Assuming you always enter exact match string for your test, you can use the org.openqa.selenium.Keys for sendKeys()
elem.sendKeys(Keys.ENTER);
break;
}
}
}

System.Windows.Forms.ListView Check box is not recognized by UIA verrify

I am quite new to UI Automation and UI Verify tool.
In our application, we are using System.Windows.Forms.ListView with CheckBoxes property set to true.
The CheckBoxes property allows you to display a check box next to each item in the list. This enables your application to display a list of items (and subitems if the View property is set to View.Details)
So far individual row and all values in each row is identified. Only checkbox is not recognized by UI verify.
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent()
listView1.CheckBoxes = true;
listView1.View = View.Details;
listView1.Columns.Add("Automation");
listView1.Columns.Add("result");
listView1.Items.Add(new ListViewItem(new string[] { "1", "Pass" }));
}
}
Output: Both values "1" and "pass" are recognized by UIA verify. However the check box is not recognized.
Has anybody else experience similar behavior? and if so is there any fix for this?
Much appreciated for all the help.
Regards
Hari Hara
From what I can see the whole list item supports the toggle pattern.
So you should be able to use the toggle pattern of the row control itself.
/// <summary>
/// Toggles anything that supports the toggle pattern
/// </summary>
/// <param name="aeElement">Automation element to toggle</param>
public void Toggle(AutomationElement aeElement)
{
TogglePattern tpToggle = (TogglePattern)aeElement.GetCurrentPattern(TogglePattern.Pattern);
tpToggle.Toggle();
}
Are you using "hover" mode? Try checking the pane structure near the checkbox items in the left pane of UIA verifier window.

GXT ComboBox unselect after selection

I have a GXT ComboBox which is bound to a ListStore and has a addSelectionHandler that is called which is working fine. I have also used the combo.setEmptyText("Select an item..").
But, when the user makes a selection I'd like to have the ComboBox return to its' "no selection" state. How can I have it return to show the "Select an item.."?
StProperties props = GWT.create(StProperties.class);
ListStore<St> sts = new ListStore<St>(combo.id());
combo = new ComboBox<St>(sts, props.name());
combo.setTypeAhead(true);
combo.setTriggerAction(TriggerAction.ALL);
addHandlersForEventObservation(combo,props.name());
...
combo.addSelectionHandler(new SelectionHandler<T>() {
public void onSelection(SelectionEvent<T> event) {
System.out.println("value selected:"+event.getSelectedItem());
// handle selection
// unselect item in combo here ---
}
});
It appears there is presently a bug in GXT 3 around this issue, as reported at http://www.sencha.com/forum/showthread.php?234736, present as of GXT 3.0.4. As reported in that bug, it seems that you can call first setValue(null), followed by redraw(true) then setText(null) on the field.
This also happens to a few other fields - based on the details of the report it seems probable that the bug is in TriggerField itself, so this workaround may be required for all subclasses.

What would be a good way of filtering a GWT CellList using multiple CheckBoxes?

Working in Google Web Toolkit (GWT) I am using a CellList to render the details of a list of Tariffs (using a CompositeCell to show a CheckBoxCell next to a custom cell of my own).
I want to filter the list by tariff length (12, 18, 24, 36 months etc). I would like to render a checkbox for each tariff length at the top of the list, and update the dataProvider as necessary when users uncheck and recheck a box.
I do not know in advance the set of tariff lengths, they will be extracted from the result set when the page is rendered. There could just be two (requiring two checkboxes), but possibly there could be 10 (requiring 10 checkboxes) - I only want to render a checkbox for each as needed.
So somehow I need to associate an int value with each checkbox, and then pass that int to a function that updates the list by removing all tariffs that match. I'm just not sure how to add the handler for the checkboxes and how to get the value for that particular box.
This is what I'm thinking:
// panel to hold boxes
private Panel contractLengthPanel = new HorizontalPanel();
textPanel2.add(contractLengthPanel);
// create a set of the terms, by looping the result set
Set<String> contractTerms = new HashSet<String>();
for(ElecTariff tariff : tariffs)
{
contractTerms.add(Integer.toString(tariff.getContractLength()));
}
// loop that set, creating a CheckBox for each value
for(String term : contractTerms)
{
CheckBox box = new CheckBox(term + " Months");
// set all boxes with the same name, and a unique id
box.getElement().setAttribute("name", "termBoxes");
box.getElement().setAttribute("id", "termBox" + term);
contractLengthPanel.add(box);
}
Now I'm not sure if I'm along the right lines here, but now I have each box as part of the same group (they have the same name) I would like to use that to add a handler that is called when a box is checked or unchecked, passing the box id (which contains the tariff length) to that function.
I hope this wasn't too confusingly written. Help appreciated.
There really is nothing like a "group of checkboxes" in HTML, and neither there is in GWT. There are kind of "groups of radiobuttons" though, but it's only about having their checked state mutually exclusive, it doesn't change anything to the way you work with them from code.
You have to listen to changes on each and every checkbox.
What you can do though is to use the same event handler for all your checkboxes; something like:
ValueChangeHandler<Boolean> handler = new ValueChangeHandler<Boolean>() {
#Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
CheckBox box = (CheckBox) event.getSource();
String id = box.getFormValue();
boolean checked = box.getValue();
…
}
};
(note: I used getFormValue() rather than getElement().getId(); I believe it's a better choice: it's specifically made to associate a value with the checkbox)