always clicks first menu item after hover - webdriver

I have a menu that is only visible after a mouse hover. The mouse hover works and the menu becomes visible for a moment. An attempted click action always clicks the first item in the menu. I want to command it to click any item in the list. I am currently using the id to find.
IWebElement settingsMenu = _driver.FindElement(By.Id("ctl00_ctl00_Main_Header_SettingsMenu"));
var actionbuilder = new Actions(_driver);
actionbuilder.MoveToElement(settingsMenu);
actionbuilder.Perform(); //perform menu hover, this always works
//menu items now visible
IWebElement ScheduleSettings = _driver.FindElement(By.Id("ctl00_ctl00_Main_Header_lnkSchedulingSettings"));
actionbuilder.MoveToElement(ScheduleSettings);
actionbuilder.Perform();
ScheduleSettings.Click();
The ScheduleSettings is the second item in the menu from top to bottom. The first item always gets clicked.

use this when you are building your driver
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("enablePersistentHover", false);
driver = new InternetExplorerDriver(capabilities);

Related

GluonMobile's AutoCompleteTextField scrolling doesn't work as expected

When I type something in AutoCompleteTextField it shows me a drop-down list with suggestions based on my input. If there is too much items a scroll bar appears on the right of the drop-down list. But the scroll only works on Windows desktop and only by using a mouse wheel. On mobile touch devices (android, iphone) AutoCompleteTextField always reacts as if I select an item (touch) from the drop-down list, not scroll (slide): the moment I touch the drop-down list and start sliding it up or down - it closes, and if my finger was pointing to an item the control selects it. The same thing happens when I try to move the scroll bar with mouse pointer on desktop (Windows and macOS).
The code is trivial:
#FXML
private AutoCompleteTextField<String> field;
...
field.setCompleter(s -> {
List<String> res = new ArrayList<>();
for (int i=0; i<items.size(); i++) {
if (items.get(i).startsWith(s)) {
res.add(String.valueOf(i));
}
}
return res;
});
No ResultNodeFactory is provided, so the drop-down list is populated with Labels by default. Same happens when providing a custom ResultNodeFactory.
Is it a bug or am I missing something?

Button as spinner in android

I have two buttons YES and NO.
If user click on the yes Button the Dropdown menu like Spinner should appear
which contains other parameters related to Yes.
user will select one Parameter from that menu(dropdown menu)
I used this line for spinner button
android:background="#android:drawable/btn_dropdown"
OnClick method for Button:
ArrayList<String> spinnerArray = new ArrayList<String>();
spinnerArray.add("one");
spinnerArray.add("two");
spinnerArray.add("three");
spinnerArray.add("four");
spinnerArray.add("five");
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
spinner.setOnItemSelectedListener(this);
with this code my button is look like spinner but on Click dropdown menu not appearing.
How to do this.?????
set your spinner launch mode to dialog android:spinnerMode=dialog this will display a dialog on click and let the user choose a option.

JavaFX Split Menu Button Arrow Trigger Event save clicked item in string

I have a SplitMenuButton, and I can't seem to find a way to trigger an event when the user clicks the arrow next to the button.
I would like to select item from dropdown(when mouse clicked on that item), display that in splitmenubutton and store value of that item in string to send to database.
I am not sure which event can do that, and I can not find any info on this either.
You can do something like.
for (final MenuItem item : smb.getItems()) {
item.setOnAction((event) -> {
System.out.println("Selected!");
});
}

hide css menu after click

I've got a menu like:
<ul class="sub">
<li>New</li>
<li>Open</li>
<li>Save</li>
<li>Help</li>
</ul>
which is "animated" via css hover code (nothing special). The Open option kicks off a file open function (via a hidden "input type=file" control). That all works fine, but when I'm done with the "file open" dialog, the menu is still displayed (albeit briefly). Is there any way to have the menu disappear as soon as "Open" is clicked, and have that (disappearance) render on the screen even before the "open dialog" runs?
TIA
What you want to do is hide the submenu when the window blurs. Not sure if you're using a JS library, but it would simply be like below. Here's a generic jsfiddle: http://jsfiddle.net/rgthree/b6QSP/
window.onblur = function(){
// Where "submenu" is the sub menu to hide,
// however you're targeting it
submenu.style.display = 'none';
}
Add a click event listener for the 'Open' option:
var openLink = document.getElementById('open'); // replace 'open' with element's ID
openLink.addEventListener('click', clickHandler, false);
function clickHandler() {
var submenu = document.getElementById('submenu'); // replace 'submenu' with submenu's ID
submenu.style.display = 'none';
}

Flex - Display a panel at the point where mouse is clicked

I would like to create a component(extending from spark Panel), which upon a buttonclick should show up next to the button(something like a bubble popping up or like the small box opening up when hovering up on profile links in facebook/twitter).
I tried to create a component that implements mx.core.IToolTip and provided the methods required by the interface.
And on the toolTipCreate event, set this component as the tooltip.
This works to an extent. When I bring the mouse over the button, the panel appears as the tooltip and goes away when i move the mouse away.
What I need is, the panel should appear next to the button when click on it and should go away only when I click outside the panel or click the close button present inside the panel.
Can you please provide me your suggestions on how to proceed further?
Thanks
//on the first click...
addChild( mouseX , mouseY );
//or
component.x = mouseX;
component.y = mouseY;
//then tween alpha or make visible
component.visible = true;
//for the click outside , assuming parent is not null
if( event.currentTarget == this.stage || event.currentTarget == this.parent)
component.visible = false;

Resources