How to handle mouse over click on chart area in selenium java - selenium-webdriver

If you go mouse over on above area then 3m,6m,1y and all are visible. If you go mouse down then it disable. How to handle this type of case in selenium.

As per my understanding you will have to use Action classes's mouse hover to get the pop up for months.
....Use developer tool to highlight the chart on which you need to hover the mouse, now hover the mouse to get those month's pop ups. and see in developer tools for changes in dom so that you can get their xpaths. Make sure you use "driver.click" to click on months. you can try xpath= //*[.='3m']. Just try to find out exact value of * using developer tool.

Thanks for quick response.
I have tried with your solution but the xpath is not working and give the nosuchelementexception. Because in the HTML Dom there are 2 iframe. Inside child frame we goto mouse over then it's visible . We mouse down then it is disapper. So my question is how to pause the mouse over section at certain time period so that all text are like 3m,6m,YTD,1y,All are visible and click one by one
In the DOm first div tag then the sequence order like
,, then 3m is displayed .
Could you please provide me the alternative solution?

Related

Stop Javascript once I identified an element with the inspector

I'm using Firefox to get information of a HTML website in order to do some automation with Python and Selenium. So far, stuff was great and worked as expected.
Now I have the following situation:
An element appears only when moving the mouse over an item, activated by JavaScript.
Once I move the mouse away, the element disappears, again by JavaScript.
How do I stop JavaScript immediately after I have identified the element?
I have tried:
deactivating JavaScript completely. But then the element does not even appear.
deactivating JavaScript after I used the inspector . However, pressing F8 does not work, because I'm not on the debugger tab, but in the inspector tab. I can't move my mouse since the element disappears.
Use keyboard shortcuts to switch to the debugger tab. I.e.
Use to identify the element
Do not move the mouse once you hover over the element
Press Ctrl+Shift+Z to activate the debugger tab
Press F8 to pause execution
Use the mouse or press Ctrl+Shift+C to go back to the inspector tab and analyze the element

The whole page scrolls to right when dragging events from the TreeView (schedule/external-drag-drop)

As anyone can notice it, in the schedule external drag drop demo , someone can drag the event from the TreeView list and when it get near to the right page edge then the page scrolls to the right.
Here is a screenshot showing it.
It's occuring also in our app and it's rather annoying.
We wish there will be a fix for this issue.
Greetings from Syncfusion Support.
We have checked your reported problem that dragging a TreeView node that produces the scroller in the output web page. Currently, we don’t have any property to prevent the scroll when dragging a TreeView node. However, we have already considered this as a feature from our end. It will be included in our Volume 2 Release which is expected to be released in June 2020.
Track the below link to know the feature status.
https://www.syncfusion.com/feedback/13575/need-to-provide-the-option-to-set-the-drag-area-in-treeview-component
But, you can resolve your issue by setting the target for dragArea of TreeView’s drag object in the created event. When setting the target, you can drag the element only inside the target element. It prevents the element from scrolling exceeding that element.
Please, check out the sample with the above explained solution.
Sample: https://stackblitz.com/edit/react-jqzozo-gqpyve?file=index.js
onCreate(){
this.treeObj.dragObj.dragArea = "body";
}

Scroll down on the terms and condition Textbox and click on Agree selenium

I am working on Protractor tests. Recently my web page changed where the terms and conditions are inside a textbox. Button Submit works only when the user scrolls through the textbox and clicks on Agree button. I tried the following option to scroll down but it is not scrolling down. Any help is greatly appreciated.
var scrollbar = element(by.id('terms-conditions'));
var checkbox = element(by.id('checkbox'));
scrollbar.click()
browser.executeScript('arguments[0].scrollIntoView()', scrollbar.getWebElement());
browser.executeScript('window.scrollTo(0,670);')
checkbox.click();
I followed the below link too but no luck.
Protractor: Scroll down
The second js execute statement you are using contains Window.scrollTo which references an open window in a browser. and using it only scrolls the complete window but not the pop-ups that appear inside a browser window
Refer here for documentation on Window.scrollTo
Normally terms and conditions shows up in a pop-up or may be a div and hence Window.scrollTo doesn't work
there are two ways you can do it
SOLUTION 1: use Jquery scrollTop() to scroll inside a specific webElement
Step 1: Identify the exact div that holds your terms of Service scroll bar
Step 2: Refine your js statement by trying directly in Chrome console
$('.modal-body').scrollTop() -> This returns the current position of scroll
$('.modal-body').scrollTop(10000) -> This sets the value of top position
Step 3: Incorporate this in your protractor script
browser.executeScript('$('.modal-body').scrollTop(10000)');
You can professionalize this by passing the element & scroll amount as arguments. Refer here
SOLUTION 2; The best way I see to submit a pop-up is not to deal with interface but to deal with the 'form' element behind it. Similar to how we deal with file uploads.No fuss & effective
May be try something like this, by making button visible first and then submit form
browser.executeScript is an asynchronous call, so you will need to put it into the controlFlow so that it will complete before clicking the checkbox:
scrollbar.click();
browser.controlFlow().execute(function() {
browser.executeScript('arguments[0].scrollIntoView()', scrollbar.getWebElement());
browser.executeScript('window.scrollTo(0,670);');
});
checkbox.click();

accessing invisible popup in selenium webdriver?

in a interview they have asked below questions please tell me code or approach ...
1-how to access invisible popup.in selenium alert pop can be accessible using alert.accept() but if alert popup is invisible then how can we use.
2-code for automatic image display slider,some image slider has next and previous button we have to click next or previous so please let me know how to develop it in both way by clicking next button on image or automatic image display slider
i am using selenium web driver,java,Firefox
thanks a lot
For the 1st question, AssertEquals will help us to go through invisible pop-ups and for the second one, I am not sure that they have asked the slider next or previous button will be on image....if it is outside image, then we can verify that if its present than click on particular id else not.

Show NotifyIcon Context Menu and Control Its Position?

I'm trying to show a context menu when I left-click a NotifyIcon. Just calling NotifyIcon.ContextMenuStrip.Show() doesn't work very well. A solution has been posted here before that calls a secret method using Reflection:
Dim mi As System.Reflection.MethodInfo = GetType(NotifyIcon).GetMethod("ShowContextMenu", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)
mi.Invoke(Icon, Nothing)
This works great, except that I also need to control where the menu is shown. I want to wait for the SystemInformation.DoubleClickTime to elapse between receiving the NotifyIcon.MouseUp event and displaying the menu, so that I can handle single-clicks and double-clicks separately. But invoking the ShowContextMenu method displays the menu at the current mouse position when ShowContextMenu is called, not when the icon was actually clicked. Which means that if the mouse moved during the DoubleClickTime, the menu will be displayed in a different part of the screen. So if I can control where the menu is shown, I can just save the mouse coordinates when I receive the MouseUp event, and then I can ensure that the menu is displayed near the icon. Is there a way to do this?
Thanks in advance.
Well, I just discovered that there are existing programs that exhibit this same behavior. I just went through all the icons in my system tray and about half of them do it. If you left-click the icon and then move the mouse during the delay before the menu appears, the menu will appear at the last mouse location, wherever that is on the screen. Snagit is one application that does this. Outlook is the only program in my tray that always shows the menu where I clicked the icon. But Snagit looks like it's using a .NET ContextMenuStrip, while Outlook is probably using a native menu.
So either this is standard behavior, or it's a problem that no one else has been able to solve either. And as a user, I've never noticed this behavior until yesterday when I was testing my own application. So I guess it's not that big of a deal and I won't worry about it.

Resources