How to click element with zero height with Capybara? - selenium-webdriver

The error I'm getting is: element not interactable: element has zero size
I have an element with a button tag with text. However, the element.style has two attributes of 0px height (and 0px padding, if that matters).
The only workaround I've found is to interact with some other element that I can find (higher up in the hierarchy of the markup), and then use x and y offsets to click this button. However that ends up flaky because the size of the element can change, and the button is off to the lower right corner.
I'm willing to go the extra mile and calculate the proper coordinates, but I'm not able to figure out how to get the width of the element either. I'm also willing to just use some javascript to click as a last resort. Ideally I'd love to know if there is something more clean and elegant for this problem.
Thank you!

I think you can enable js for this test and use a trick for it.
Smth like that:
page.execute_script("$('#container img').css('height', '10px;')")
find('#container img').click
page.execute_script("$('#container img').css('height', '0')")

I ended up using actionbuilder to work around this problem, like this:
el = find('button', :text => '+ 1').native
actionbuilder = page.driver.browser.action # Use actionbuilder to workaround zero height button
actionbuilder.click(el).perform
I'm not sure if this is the way to go but that seems to have helped and maybe might help someone else out there.

Related

smooth horizontal scroll - REACT THREE FIBER

I've been trying to make a small horizontal scroll with react three fiber so I can later add some WebGL Distorsion on the elements and even though i succeeded in the most basic way, there are still some things that need improvement :
(here is the codesandbox corresponding :https://codesandbox.io/s/horizontal-scroll-with-react-three-fiber-c0okfu?file=/src/Scene.js)
first and foremost I want a smooth scroll and can't seem to be able to make it, I used the lerp function to make it but the result doesn't work very well :
let scroll = 0;
scroll = (scroll - scrollTargetMapped) * 0.03;
// any other frame, groupRef.current is undefined, don't really know why
// but because of it, i must put my logic inside an if loop
if (groupRef.current) {
groupRef.current.position.x = THREE.MathUtils.lerp(
scroll,
-scrollTarget,
0.01
);
}
secondly, the elements on my scene are placed kind of in a random way and the scene is not at all responsive. I would love to mimic the html logic and put my first element like 50px away from the left side of the screen but not sure if it's really possible with react threejs :)
If someone has any answer to one of those question, I take it 🙂
Thanks in advance !
For those interested, I managed to find a solution, using one of drei components : ScrollControl, it works perfectly !
https://codesandbox.io/s/horizontal-scroll-with-react-three-fiber-c0okfu?file=/src/Scene.js
For more info on the said component, check out the doc : https://docs.pmnd.rs/drei/controls/scroll-controls

Openlayers draw poylgon remove double click option

I am building a UI using Openlayers 4. The request I have received is to not allow the user to double click to complete the current .Draw interaction. I have manages this on the LineString by using the maxPoints option and only allowing the user to draw straight lines (as per my requirements).
I need to do the same thing with the Polygon but cannot get it to work. I have tried using the finishCondition but this does not help.
Is this something that can be done in Openlayers?
JS Fiddle is throwing massive errors on my machine at the minute, I'll add an example as soon as I can.
EDIT
Here is a basic jsfiddle. You can toggle the return boolean from finishCondition, when set to true the single and double click end the polygon drawing. When set to false the drawing cannot end.
I need to find the codtion that will allow me to return false if the user double clicks and true otherwise.
Ok, after a bit of further investigation I have found a solution, shown in this jsfiddle.
I have used the on drawstart event to calculate and set the coordinate of the first point in the polygon, in the finishCondition I find the current pixel it is at, then using that to see if it is within 10px of the clicked point, if it is end the polygon if not then keep drawing.
I am happy if anyone out there can show me a more elegant way to do this, but for now this seems to do the trick.
Had a look go with this aswell, and you can return whether or not the the finish coordinate of the interaction
finishCondition: event => {
return this.interaction.finishCoordinate_ === this.interaction.sketchCoords_[0][0];
};

maya makePaintable attribute

stupid question but I m having an issue with that.
Can you make more than 1 attribute paintable on the same shape ?
I am adding 3 double array attributes for testing purpose and I make them paintable trough a loop while adding them.
When I do that, I can t paint them through my test and to verify that i tried painting it via right click on the mesh -> paint -> mesh and I only see the usual paintable attributes + the first one I defined...
Is there anything specific to do to declare more than 1 attributes paintable ?
Thanks !
I found out why it wasn't working. The documentation for makePaintable is wrong ...
cmds.makePaintable('node','attribute') like shown in the documentation doesn't work. Instead, you have to do cmds.makePaintable('nodeType','attribute') and your mesh has to be selected (I suppose as you don't specify it in the command)
It is now working.

ios 6 MapKit annotation rotation

Our app has a rotating map view which aligns with the compass heading. We counter-rotate the annotations so that their callouts remain horizontal for reading. This works fine on iOS5 devices but is broken on iOS6 (problem seen with same binary as used on iOS5 device and with binary built with iOS6 SDK). The annotations initially rotate to the correct horizontal position and then a short time later revert to the un-corrected rotation. We cannot see any events that are causing this. This is the code snippet we are using in - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id )annotation
CATransform3D transformZ = CATransform3DIdentity;
transformZ = CATransform3DRotate(transformZ, _rotationZ, 0, 0, 1);
annotation.myView.layer.transform = transformZ;
Anyone else seen this and anyone got any suggestions on how to fix it on iOS6?
I had an identical problem so my workaround may work for you. I've also submitted a bug to Apple on it. For me, every time the map got panned by the user the Annotations would get "unrotated".
In my code I set the rotations using CGAffineTransformMakeRotation and I don't set it in viewForAnnotation but whenever the users location get's updated. So that is a bit different than you.
My workaround was to add an additional minor rotation at the bottom of my viewForAnnotation method.
if(is6orMore) {
[annView setTransform:CGAffineTransformMakeRotation(.001)]; //iOS6 BUG WORKAROUND !!!!!!!
}
So for you, I'm not sure if that works, since you are rotating differently and doing it in viewForAnnotation. But give it a try.
Took me forever to find and I just happened across this fix.

Very Strange: Every other time an array is updated its values are screwed up

You can see the code there: http://jsfiddle.net/jocose/CkL5F/901/
(double click on the box and move your mouse)
NOTE: This is a simplified example that is part of a larger system. My ultimate goal is to manipulate individual vertices of a path.
Update: I crunched the numbers and the math actually apears to be correct. What I want to do is calculate the offset from each point to the mouse, and then move that point to the mouses position + the offset.
So if I have a mouse of 224 then 224-103 = 121 then I add: 121+224=345
These creates a cycle of ups and downs that I am seeing. I don't know why these is stumping me so badly, any help would be much appreciated.
I need to manually update a Raphael path element.
To do this I convert an absolute path into an array using Raphael great built in function "parsePathString"
I then loop through that array and modify the values based off the mouse position.
The update is done to the X values only, and is in real time; called each time the mouse moves.
When the element moves it flickers back and forth between the correct position and some anomalous one.
I have no clue why its doing this. I have spent almost 5 hours trying to figure this out and I'm officially stuck.
Here is a sample of the result where you can see the values jumping around:
MOUSE224
M,103.676287
MOUSE225
M,346.323713
MOUSE227
M,107.676287
MOUSE228
M,348.323713 12
MOUSE228
M,107.676287
MOUSE229
M,350.323713
MOUSE231
M,111.67S287
MOUSE232
M,3S2.323713
MOUSE233
M,113.676287
MOUSE233
M,3S2.323713
Here's my version of your fiddle modified to do what I think you need. At least, it seems to work. It's the same type of problem I had to fix for the Raphael 2 transformations here.
Basically, in your mousemove, I've changed mx to be a calculation of the offset between where your mouse is now and where it was the last time mousemove was called. Your move() function now only has to add this value to the x-coords.
Hope this helps you out somewhat

Resources