webdriver not clicking on button - webdriver

I have a scenario where if if mouse hover a box it shows the button on which I want to click. The html is something like this:
<div class="Box on which hovering i get the button">
<div class="special button comes only on hovering">
I am using this code to click on the webdriver but without any success:
(IrenderedWebElement)driver.hover(locatorOfBox)
(IrenderedWebElement)driver.click(special button locator)
if(button.isDisplayed)
driver.click
I have tried putting wait also in between hover and click but of no use. I am stuck so looking for answers.

Use the Actions class. Here's an example where the "Rounds" sub menu item is only visible after hovering on the "Default management" top level menu item:
IWebElement topLevelMenu = driver.FindElement(By.LinkText("DEFAULT MANAGEMENT"));
var actions = new Actions(driver);
actions.MoveToElement(topLevelMenu).Perform();
driver.FindElement(By.LinkText("ROUNDS")).Click();

Try click first div class and after that click second.

Use Xpath (to locate exact button- it helps when id is autogenerated) to click on button
driver.findElement(By.xpath("//*[#class='Box on which hovering i get the button']/div")).click();
Hope below link will help to manually generate xpath
http://www.guru99.com/accessing-links-tables-selenium-webdriver.html
see under "Reading a Table-->XPath Syntax"

Related

How to remove unknown property created during opening of a mat-select modal

I am facing problem on removing unknown division created during opening of a mat-select.
When I am opening a modal and after selecting values ,I need to click directly on the button given on side but because of some property of modal a div is getting created and I have to do two clicks on the button to apply changes.
Right now when I am clicking outside the mat-select modal to make it close then clicking on button it is going correct. But I need to open modal -> select options -> direct click on the button given.
Something in the background is blocking the first click when opening a mat-select modal. I am not able to see what is that. Is there some css property that can be block ? I am not getting exact hidden problem.
Modals in Angular Material create something that's called 'backdrop' by default. This backdrop is like a layer right behind your modal, filling the whole page. If you click somewhere on the page, your target will be the backdrop, which then closes the modal.
So for you to achieve, what you want to achieve, you have the following options:
edit the backdrop behavior to not prevent the default click action, so that clicks on the backdrop close the modal but also trigger the action you want
remove the backdrop on opening of the modal (this can be done by setting a flag hasBackdrop in the open methods config parameters) and close the modal programmatically by triggering the close method of the MatDialogRef
This is standard modal behavior, you should include all your needed options either before opening a modal or in the modal itself after being opened.

Right click menu css

Basically I just wanted to know how to change the looks of the right click menu using css. I haven't tried anything because I have no clue were to start.
Thanks in advance
unfortunately, you can't change the right click menu style using CSS, but you can disable it and create one from scratch using HTML, CSS and Javascript
you can handle the right click event (context menu event) by adding this code:
document.addEventListener('contextmenu', function(e){
e.preventDefault();
});
This part e.preventDefault(); will disable the default behavior of the right click and the context menu will no longer appear, now you need to add a function and new style for your styled context menu
If you are still not sure how to make this here's a tutorial for the complete thing you want to achieve https://www.sitepoint.com/building-custom-right-click-context-menu-javascript/

Eclipse Scout Neon: Menu and Tooltip on a field

This is a screenshot if you put a Menu on a StringField:
This is a screenshot if you put a Tooltip on a StringField:
This is a screenshot if you put a Menu and a Tooltip on a StringField:
the (i) icon from the tooltip is the button to open the menu list.
the tooltip text is not visible.
Did I miss something?
Is this a known issue?
Yes, this is a known issue. If a tooltip and a menu are provided, a combined popup should be shown including the tooltip text and the menu items. But this has not been implemented yet. Feel free to open a bug.
However, if you only have one action you could set the property hasAction to true instead of using a menu. This will bring up a clickable arrow inside the field, actually intended to follow a link or open the email client. But you could also use it for any other action as well, just implement execAction. Please note that this feature is only available for string fields so far.
StringField with hasAction=true:

MaterializeCSS Dropdown Link not clickable

I'm experiencing a frustrating problem with MaterializeCSS dropdown links created on Wordpress Menus. I can see the link when I hover over the top level items, e.g. About FAIRDOM, but I can't click any of them. I know it's an issue somewhere perhaps in having a hidden element above that may be catching the click event, but I can't see where. Anyone with any idea of where the issue is in this site http://beta.fair-dom.org/ ?
MaterializeCSS built their dropdowns "mobile-first". Essentially, what that means for you is that the JS that powers the dropdowns explicitly disables the href on click for all dropdowns. This is a because, on mobile, a user cannot hover and can only touch.
However, if you're still wanting to get around this, you can try out the following (assuming you're using jQuery):
<script>
$('.dropdown-button').click(function() {
window.location.href = $(this).attr('href');
}
</script>
Try sticking that just before you close the body tag,

Control a hidden menu behind a button with pywinauto

I'm very new to pywinauto ans I love it already. But I have a problem:
I want to automate an old software program with pywinauto and can control most of the buttons. But there is a certain button when clicked, there appaers a menu with icons (not the windows style of menu but a custom menu). The button's name is "Toolbar2" so I guess it's not a normal button.
With this code I can click the button I want to. When I use "ctrl.Click(), the button doesn't get clicked, I need to use ClickInput(). With the normal buttons I do can use Click().
w_handle = pywinauto.findwindows.find_windows(title=u'P2-NLTlog013', class_name='TfrmDisplayFilteredData')[0]
window = pwa_app.window_(handle=w_handle)
window.Click()
ctrl = window['ToolBar2']
ctrl.ClickInput()
My question now is: How can I get the names of the items of the hidden menu And click them. I already used this code, but then he gives a 'MatchError'.
window = pwa_app.Window_(best_match='ToolBar2', top_level_only=True).ChildWindow(best_match='PopupMenu').Click()
window.Click()
I don't know what language the software was written in...
Thanks in advance,
Fred
You may get the menu object by window.Menu() and then try to access subitem by menu.Items()
Useful methods: menu_item.Index(), menu_item.SubMenu()

Resources