-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Allow to use different drivers in the same test suite #15
Conversation
Is this still a problem in the v1.0.0 release of appium_capybara? |
Yes same problem with 1.0.0 |
is_appium_driver = driver.instance_of? Appium::Capybara::Driver | ||
browser_initialized = is_appium_driver ? driver.browser_initialized? : true | ||
|
||
if @touched and browser_initialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use &&
instead of and
. and
has weird precedence rules.
a = true and false; a
=> true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because =
takes precedence over and
, add parenthesis to prove it
a = (true and false); a
=> false
On the other hand, and
takes precedence over if
if true and false; 'yes'; else; 'no'; end
=> "no"
Therefore in ruby if a and b
is fully equivalent to if a && b
But I'll edit it to follow your suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The and and or keywords are banned. It's just not worth it. Always use && and || instead.
See the github style guide.
squash to one commit:
I think the code looks fine once the issues are addressed. /cc @sbonebrake what do you think? |
# Next line is a work around for issue https://github.com/jnicklas/capybara/issues/1237 | ||
if @touched && driver.browser_initialized? | ||
# Workaround for issue https://github.com/jnicklas/capybara/issues/1237 | ||
is_appium_driver = driver.instance_of? Appium::Capybara::Driver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check should be inside the if statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could, but it is easier to read like this won't you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, you're right. I missed this was used in the next line. 👍
once this is squashed then the code looks good to me. |
I agree this should be fixed, but your solution doesn't allow this to work with other drivers that may have implemented .browser_initialized? or patched to have it. Instead of checking for "driver.instance_of? Appium::Capybara::Driver", why not "browser_initialized = driver.respond_to?("is_initialized") ? driver.is_initialized? : true". In fact, I should see if Capybara would accept that as a fix for the bug. |
@bootstraponline rebase done. On my side I can't see how it affected the pull request, can you? @sbonebrake Well your thought is correct but it does not apply in this case, because a correct implementation of a Capybara driver is to inherit from its class and that's what all driver does. |
you should force push |
Ok now? |
I'm still seeing 3 commits. You ran all 3 commands?
|
looks correct now. I agree with @sbonebrake about using |
The browser being reinitialized during session reset is an issue that affects all drivers, not just appium capybara. Using respond_to? is the best way I know to allow users to make their own patches to implement browser_initialized? or use it in any custom drivers they have. |
That's not what I discuss about. AppiumCapybara is a very useful project, and I believe it is purposed for a long life when the community will start to understand its advantages. But it is, as of now, made of a very bad design. Let me explain. This are some highlights on the current design:
This mix-up of libraries and the abuse of monkey patching will lead to several problems. 1) if Capybara update its code you will have issues 2) it is impossible to maintain compatibility with different version of Capybara on the long run 3) your patches may already not be compatible with existing drivers. Your project is still young and problems dues to this design already start to rise: AppiumCapybara is breaking Selenium (which is turn lead me to open this issue). One of those monkey patch is forcing the base implementation of Capybara to call Each and every other existing driver inherit from Capybara classes or define their own classes from scratch. This is the correct way to go and you should do the same.
As a conclusion, even is my 3 points above demonstrate that it is useless, I will still update to |
I agree it'd be better without the monkey patches. The
I'm just volunteering for appium_capybara because I want the project to be successful. I don't use it at work so the current design being permanent or not depends on contributors. If you want to improve the design and @sbonebrake agrees with the changes then I'm happy to see them merged into the project. |
@sbonebrake what do you say? |
Addressing a the issues one by one:
|
Yes, I'd expect the selenium nodes to be useful for mobile web. |
Nice. And I pretty sure we could find a clean solution to the |
What do you guys think? Merge this is now or cross our fingers and hope my PR for issue teamcapybara/capybara#1237 is pulled in soonish? I'm leaning towards merging this now even if we have to pull it back out for the next version. |
I added a I guess it's going to take a bit for them to merge and even longer to make a release. I think it makes sense to merge now and revert later. |
Allow to use different drivers in the same test suite
In my test suite I use different drivers, including appium_capybara.
I get this message for tests that use other drivers (selenium for example)
This pull request fix it