Hovering with moveTo or moveToElement - nightwatch.js

I'm having trouble getting the background color of a link using the following code and selenium stand-alone 2.53.0 and Firefox 50.0.2661.75 m or Chrome latest:
Although during the test I don't see the mouse moving, at the bottom of the browser's window in the status bar, I do see the URL change to the HREF of the link.
I cannot seem to trigger the hover event for any elements, so the background color is always the default color and not the hovered stated color. Any ideas around this?
browser.moveToElement('a[href="http://www.foo.com"]',2,2, function() {
browser.pause(2000)
.getCssProperty('a[href="http://www.foo.com"]', "background-color", function(results){
console.log('color: ' + results);
});
});
If I remove the getCssProperty from the callback, I'm still not getting the right background color for hover and not seeing the mouse pointer move:
browser.moveToElement('a[href="http://www.foo.com"]',2,2)
.pause(2000)
.getCssProperty('a[href="http://www.foo.com"]', "background-color", function(results){
console.log('color: ' + results);
});

You won't see your physical mouse pointer move. Selenium doesn't move your mouse it just simulates the events in the browser.
Also, if your physical mouse is in the window, it'll mess with the events being generated and you won't see colors change properly, etc.
The fix: What you are doing above is correct, but you need to move your actual mouse to the bottom right-hand corner of the screen before the test starts. Leave it there for the duration of the test.

Related

How can I remove the delay of a QML ToolTip?

I rebuilt a periodic table using QML and stumbled upon the following problem. Due to size limitations I decided to reduce the amount of information that is shown to a minimum and instead implemented the option to hover over a certain element which causes a tooltip to show up, offering more information.
Periodic table
tooltip with more information
My problem is, that when you move the cursor to take a look at a different element, the tooltip will not stop showing immediately but slowly fade out instead. Rambling from side to side with your mouse will show this for example:
delayed tooltips
Is there a way to remove this fadeout and let the tooltips disappear immediately instead? Thanks in advance :)
This is defined in the style you are using. Either you write your own style, a custom ToolTip or overwrite manually every time. To fix it you need to overwrite the exit transition.
Button {
id: button
text: qsTr("Save")
ToolTip {
parent: button
visible: button.hovered
delay: 500
text: "This is a ToolTip"
exit: Transition {}
}
}

Firefox mousemove bugs out if left mouse button pressed on svg image

So in this little example I have a square (thumbnail) following the mouse around, in the final product it will be the place where the dragged item will be visible. I ran into a problem however that if I try to drag and drop a svg <image> in Firefox it bugs out and doesn't follow the mouse anymore.
http://jsfiddle.net/Lx7besrw/
Same applies if you have different mouseEvents, they all bug out and stop working until you unpress left mouse button and move again. I've tried e.preventDefault e.stopPropagation and return false to prevent weird behaviour but without luck.
Any help would be GREATLY appriciated.
This solved my problem:
$(document).on('dragstart', function(e){
e.preventDefault();
});
https://bugzilla.mozilla.org/show_bug.cgi?id=511188

Highslide: Shrink image back when clicking in outer area

The only thing which I disklike whith highslide is the fact that when I click a thumbnail and it gets bigger I only can shrink it back when I click exactly in the image area.
Is it possible to shrink the image back when clicking outside the image area?
(and optional also shrink it back when I hover outside the image with the mouse cursor?)
Thanks
If you use a dimming background (hs.dimmingOpacity=0.7, for example), clicking outside the image area will close the expander. This requires highslide-full.js. If you don't want a dimming background, just set the opacity to a tiny value, like hs.dimmingOpacity=0.01.
It might be possible to include an onAfterExpand event to close the expander when you hover outside the image, but I think I can guarantee that you wouldn't like it. If a visitor clicked on a thumbnail, but didn't just happen to have his mouse over the image when it opened, it would immediately close again. That would be very frustrating behavior for the site visitor.

jQuery hover event not firing on hover

So if you attach some function on the hover event it won't fire if the mouse is already within th hovering area during page load, and is not moved. You actually have to move the mouse a bit to the event to fire.
Example:
move the mouse to the hover-effect area
hit the mouse with an axe
reload the page with F5
=> hover function not fired :(
Why?
And is there a fix?
This is expected functionality, hover is simply the combination of "mouseOver" and "mouseOut" so if your cursor is over the element on page load, it never technically moves over the element. Unfortunately without a mouse move, there is no way for the javascript to determine the position of the mouse, or the element it is currently over.

jquery layout and dynamic draggable div issue

I am using jquery layout plugin and have the following situation that I cannot find a solution. How do I make the center pane increase its size permanently by dragging the div beyond the bottom border.
I have a left pane and a center pane. I dynamically generate div
when the user clicks on the left pane. The divs are generated and
dropped on the center pane. The divs are draggable and resizable.
Everything works fine with dragging and resizing on the visible center
area. The moment I drag the div beyond the bottom, the scroll bar on
the center pane appears and it seems the center pane is extending to
accommodate the new position of the dragged div. But the moment I try
to resize the div or add another div, it jumps to the top section of
the div and resets the scrollbars. I checked the center div height in
firebug and it remains at the same height when initialized
even after dragging the new div beyond the bottom.
Here is the test page html code.
Just copy/paste entirely into a html page. On the left pane, click on the "Add new" button will add new div that is draggable and resizable.
Click on "Add new"
Drag the newly added div beyond the bottom of the center pane.
The center pane shows the scrollbar as it is suppose to.
If you check the center div's height in firebug, it is not changing
Now try resizing the newly added div by dragging its handle
It jumps to the top and the center box loses its scrollbar.
I could not paste the complete html page so here is the reference to the code at the bottom of this thread
http://groups.google.com/group/jquery-ui-layout/browse_thread/thread/ca922aa44c0048ee
And here is the test link http://jsfiddle.net/yZc63/
I am surprised no one has come across this situation before? Even without the layout plugin, my solution is not very pretty. In order to simulate the page without the layout plugin, I had to keep the top and the left pane using position:fixed property in css. And there is no center div at all. I add the new div directly to the body of the html. The reason is I don't want to see additional scrollbars on top the browser scrollbars. In other words the center pane should scroll when the browser scrollbars are moved. I am attaching the solution so you have an idea.
I am open to any solution even without the layout plugin if i can simulate the previous attached file using any other approach. i am attaching my page without the layout plugin but am not sure if that is the only elegant solution left.
You can check the solution here http://jsfiddle.net/c7wrT/
Is adding the dynamic div directly to the html body a good approach?
I ran into same situation and this answer helped.
https://stackoverflow.com/a/33004821/2139859. Updated Fiddle: http://jsfiddle.net/bababalcksheep/yZc63/11/
$(".removalbe-recom").draggable({
appendTo: "body",
helper: "clone",
revert: "invalid",
cursor: "move",
containment: "document",
zIndex: 10000,
scroll:false,
start: function (event, ui) {
$(this).hide();
},
stop: function (event, ui) {
$(this).show();
}
});

Resources