Unable to select the aria-activedescendant combobox element in java - html

Im finding it hard to select the items from the combobox element. This combobox is something different. When i drag down the items, i could see the actual value of the item(i.e. aria-activedescendant="react-select-4--option-3"). After selecting the particular item, the value has got changed to "aria-activedescendant="react-select-4--value"". Plz suggest me the best solution to click the item. You have to specifically note this "aria-activedescendant="react-select-4--value"" in input section under html code.
Tried with below code. I was able to just click the combo box element but not the value. I used id="react-select-4--value" to click the combo box, It errors as "element not clickable at point". Technically the system understands something wrong.
public void ScrollAndClickOnElement(String loacator,String LocatorValue)
{
WebElement element = null;
if(loacator.equalsIgnoreCase("cssSelector"))
element = driver.findElement(By.cssSelector(LocatorValue));
else if(loacator.equalsIgnoreCase("xpath"))
element = driver.findElement(By.xpath(LocatorValue));
else if(loacator.equalsIgnoreCase("id"))
element = driver.findElement(By.id(LocatorValue));
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);",element);
element.click();
}
public void WaitAndClickElement(String locatorType,String locatorVaue)
{
WebDriverWait wait = new WebDriverWait(driver,50);
if(locatorType.equalsIgnoreCase("cssSelector"))
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(locatorVaue))).click();
else if(locatorType.equalsIgnoreCase("xpath"))
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(locatorVaue))).click();
else if(locatorType.equalsIgnoreCase("id"))
wait.until(ExpectedConditions.elementToBeClickable(By.id(locatorVaue))).click();
}
ScrollAndClickOnElement("id", AssessmentPageData.ElevatorManufacturer);
WaitAndClickElement("cssSelector",AssessmentPageData.Appollo);
Referred to this link and used 'select' method, but it errors as "Element should have been "select" but was "span""

Found the below solution finally,
public void SelectBootStrap(String textval){
WebElement listElement = driver.findElement(By.xpath("//div[#class='Select-menu-outer']//div[text()='"+textval+"']"));
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);",listElement);
listElement.click();
}

Related

InfoBox is empty

My Cesium infobox is empty after I dynamically select an element.
This is how I'm selecting the element.
public selectById(id: string): void {
console.log('selecting ' + id);
if (id != null) {
// this.viewer is Cesium.Viewer => https://cesiumjs.org/Cesium/Build/Documentation/Viewer.html?classFilter=viewer
this.viewer.selectedEntity = this.viewer.entities.getById(id);
// viewer.flyTo messes up the camera pitch
this.viewer.camera.flyTo({destination: this.viewer.selectedEntity.position.getValue(Cesium.JulianDate.now())});
}
}
The entity is selected, the camera flys to it just fine, and the Cesium infobox displays the entity name in the title just fine, but doesn't display the description. If I select the entity by clicking on it, the box displays the description just fine.
I can't find anything to force the InfoBox to redraw, or see anything else I need to set for the InfoBox to update. So what am I missing?
I tried setting this.viewer.infoBox.viewModel.description but that didn't help either.
Apparently this was caused by selecting the entity while the map container was set to display: none. I was able to fix this by delaying the execution until focus returned to the map.

AS3 set focus on specific component

I have a form with several component: datagrid, textArea, text input...
For each component FocusIn Event is available.
var objTarget:String;
protected function memo_focusInHandler(event:FocusEvent):void
{
objTarget=event.currentTarget.id;
}
With memo_focusInHandler, I know which has focus.
My goal is to backup last focus objet, and re open Windows with focus on this object.
I try to do this:
objTarget.setfocus();
But it doesn't work. Could you help to found the best way to reach my goal.
String is not a display object, thus it can't be in focus. The representation of string on the stage is a TextField.
In as3 you can set focus to the desired target by using stage method:
stage.focus = myTarget;
Please see the corresponding documentation section: https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#focus
There is no need (that you've shown) to work with the string id reference. It would much simpler (and slightly more efficient) to work directly with the object reference.
var objTarget:Object; // Object instead of type :String
protected function memo_focusInHandler(event:FocusEvent):void {
objTarget = event.currentTarget; //instead of the currentTarget's id property, assign the current target itself
}
Then, when you want to reset focus, you can do:
if(objTarget is TextInput || objTarget is TextArea){ //make sure it's a text input or text area first - optional but recommended if you don't like errors
objTarget.selectRange(objTarget.text.length, objTarget.text.length); //set cursor to the end
objTarget.setFocus(); //focus the text input/area
}
I found a solution:
this[objTarget].selectRange(this[objTarget].text.length, this[objTarget].text.length);
this[objTarget].setFocus();

Change data template when the user selects it

I have two datatemplates. One is the default and the other one is for when the user selects this item. I need to give the selected item double width and height of the normal template. How can I do this?
What you want to do is not difficult, but it is not solved by swapping the data template. Instead, it is accomplished by using Visual States in XAML. A Visual State allows you to create multiple "views" of your XAML (for example, what it looks like when it is selected and when it is not selected) and to switch between those easily. Swapping data templates is a big deal, Mostafa, and can result in your UI flickering because the underlying subsystem has to re-render so many parts of the visual tree.
If you want to learn more about the Visual States, you might read over the blog article I wrote on the same subject.
http://blog.jerrynixon.com/2013/11/windows-81-how-to-use-visual-states-in.html
The only problem now is to figure out how to trigger the visual state when the item in a gridview or listview is selected. First, you should know that IsSelected is a property on the gridviewitem or listviewitem control that houses your item. However, it's tricky to reach that property and the most common approach is to sub-class your gridview/listview and override PrepareContainerForItemOverride and set the binding in code-behind.
Like this:
class MyModel
{
public bool IsSelected { get; set; }
}
class MyList : Windows.UI.Xaml.Controls.ListView
{
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
{
var model = item as MyModel;
var listViewItem = element as Windows.UI.Xaml.Controls.ListViewItem;
var binding = new Windows.UI.Xaml.Data.Binding
{
Source = model,
Mode = Windows.UI.Xaml.Data.BindingMode.TwoWay,
Path = new PropertyPath(nameof(model.IsSelected)),
};
listViewItem.SetBinding(Windows.UI.Xaml.Controls.ListViewItem.IsSelectedProperty, binding);
base.PrepareContainerForItemOverride(element, item);
}
}
I hope this helps.
Best of luck!

GWT How to get checkBox value when click button

I am new to GWT. Here is my checkBox code, I want to know whether it is chose or not when user click button.
CheckBox checkBox = new CheckBox("Disable Credential");
checkBox.setValue(false);
flexTable3.setWidget(0, 0, checkBox);
checkBox.getElement().setId("checkBox");
flexTable3.getFlexCellFormatter().setColSpan(0, 0, 2);
flexTable3.getFlexCellFormatter().setHorizontalAlignment(0, 0,
HasHorizontalAlignment.ALIGN_CENTER);
Here is my getting checkbox value code in onclick handler class :
InputElement checkBoxElement = (InputElement) (Element) DOM
.getElementById("checkBox");
if (checkBoxElement.getValue() != null) {
checkBox = checkBoxElement.getValue() != null;}
Based on my code, the checkBox result is always false no matter it's chose or not. Any idea how to figure it out?
In GWT you almost never need to set an id on an element and get an element by id. You already have your CheckBox widget in your code - use it.
checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean> () {
#Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
// check box is selected
}
}
}
Have you tried the onValueChange handler?

how to identify JComboBox whether is disabled or enable inside its renderer class

I have a JComboBox contains following iems
{ "select" , "one" , "two" }
i need a separate background for first item so ,
i have made a condition in it's renderer like
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value != null){
Item item = (Item)value;
setText(item.getDescription());
}
if(index==-1){
setBackground(new Color(199,209,210));
setForeground(Color.BLACK);
}
return this;
}
}
so my question is if we disable a JComboBox, i have to made -1th index of component background color to someother color
like
if(index==-1){
setBackground(Color.RED);
}
please advice
The simplest way is always the best. Since you assigning renderer to a combobox, why don't you pass the combobox into it? Just create a custom renderer that holds the reference to a combobox then use the stored reference inside of your getListCellRendererComponent method
Maybe I'm missing something here, but if a JComboBox is disabled, then that means that it cannot popup its list of items. But if it is not showing its list of items, then that means it is not using the renderer for that list.
So, why do you need to get a reference to the combobox in the renderer?