Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't able to access the popover element in iOS device (Appium) #130

Open
Ram2103 opened this issue Dec 22, 2021 · 14 comments
Open

Can't able to access the popover element in iOS device (Appium) #130

Ram2103 opened this issue Dec 22, 2021 · 14 comments

Comments

@Ram2103
Copy link

Ram2103 commented Dec 22, 2021

We cannot able to access the popover element in iOS device using Appium, whereas we can able locate the popover element in Android device.

@SteffeyDev
Copy link
Owner

I'm not familiar with Appium, does it work on a normal iOS device or the official simulator?

@Ram2103
Copy link
Author

Ram2103 commented Feb 16, 2022

In official simulator we can't able to access the popover mobile element.

@SteffeyDev
Copy link
Owner

Ok, I'll need a lot more details if you expect any help with this. As this library has worked for a lot of people, the issue is most likely with your setup. I would be happy to help if you can provide detailed reproduction steps.

@ben-wright
Copy link

@Ram2103 @SteffeyDev The bug seems to lie with React Native or Appium. Elements which have position: absolute nested within <Modal> do not seem to appear in appium.

To get round this with this when using react-native-popover-view simply apply add popoverStyle prop with relative position.

eg:
<Popover popoverStyle={{position: 'relative'}}></Popover>

@SteffeyDev
Copy link
Owner

Interesting, I can add this to the troubleshooting steps. Are there any side affects when you use this work-around in appium?

@SteffeyDev SteffeyDev changed the title Can't able to access the popover element in iOS device Can't able to access the popover element in iOS device (Appium) Mar 12, 2022
@ben-wright
Copy link

Only downside I see is that it can potentially be awkard to style the modal as it'll need relative positioning

@mochi08
Copy link

mochi08 commented May 10, 2022

Running into same issue here. In iOS, elements inside the popover are not selectable in Appium. Adding position:relative does indeed make the elements selectable, but styling will be tricky. I'm struggling to get my popover to size dynamically with position:relative.

Interesting thing I found is that react-native-popover-view works perfectly with Appium in andorid but not in iOS; on the other hand, react-native-modal-popover works correctly with Appium in iOS but not in android. Frustrating.

@SteffeyDev
Copy link
Owner

That is really interesting @mochi08. I just peaked through the source code of react-native-modal-popover, it also uses position: absolute inside a modal, so maybe there's something else going on?

@quizzyDev
Copy link

First of all thanks @SteffeyDev for a great package and responding to us when we need help 🍻
...
This is a really weird issue with Appium as absolutely positioned elements within a rn-modal are sometimes visible in appium desktop and sometimes they're not. (If anyone knows what the pattern is please let us know).

The fix that I used for both v4.1.0 and v5.1.2 was by setting one of the View elements to have position: relative.
For v5.1.2 though I had to do a bit of digging as the issue wasn't caused by the immediate View element around the children.

tldr; Patch for v5.1.2:

diff --git a/node_modules/react-native-popover-view/dist/BasePopover.js b/node_modules/react-native-popover-view/dist/BasePopover.js
index d6c290c..2bb3458 100644
--- a/node_modules/react-native-popover-view/dist/BasePopover.js
+++ b/node_modules/react-native-popover-view/dist/BasePopover.js
@@ -408,7 +408,7 @@ var BasePopover = /** @class */ (function (_super) {
             React.createElement(Animated.View, { pointerEvents: "box-none", style: containerStyle },
                 this.props.showBackground !== false && (React.createElement(TouchableWithoutFeedback, { onPress: this.props.onRequestClose },
                     React.createElement(Animated.View, { style: backgroundStyle }))),
-                React.createElement(View, { pointerEvents: "box-none", style: __assign({ top: 0, left: 0 }, shadowStyle) },
+                React.createElement(View, { pointerEvents: "box-none", style: { position: 'relative', flex: 1 } },
                     React.createElement(Animated.View, { style: transformStyle },
                         React.createElement(View, { ref: this.popoverRef, style: contentWrapperStyle, onLayout: function (evt) {
                                 var layout = __assign({}, evt.nativeEvent.layout);

I'd recommend patching the package before running tests and then unpatching after, rather than using this patch permanently as it may not work as @SteffeyDev intended.

@mochi08
Copy link

mochi08 commented Aug 25, 2022

@quizzyDev your solution is awesome! I'm using v4.1.0 and applied the fix in dist/Popover.js. Now I don't have to add "position: relative" whenever I use the popover and it's working in Appium. What's more is that it doesn't result in the same styling issues as before. I haven't found any problem with any of my popovers yet. Thank you very much!

@SteffeyDev
Copy link
Owner

I'll run some tests on this patch and see if this works, I would be fine including this change in the repo if there's no downsides.

@quizzyDev
Copy link

@SteffeyDev - Just updated to 5.1.4 and I can see the above patch in the compiled BasePopover.js and the BasePopover.tsx file. However I don't see the changes in the master branch atm - Just thought I'd point it out in case this wasn't intentional.

@SteffeyDev
Copy link
Owner

Thanks for bringing this to my attention, I had been experimenting and forgetting to stash before building. I re-released as 5.1.5 without these changes, I need to do more testing to make sure that won't break anything. However, I suppose you can stick with 5.1.4 if it works for you and fixes the appium issue.

@quizzyDev
Copy link

No worries @SteffeyDev - I thought that'd be the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants