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

Backdoor implementation #317

Merged
merged 24 commits into from
Dec 3, 2018
Merged

Backdoor implementation #317

merged 24 commits into from
Dec 3, 2018

Conversation

rajdeepv
Copy link
Collaborator

This is a port of one of the calabash-android features called Backdoors to appium-espresso-driver
Using this feature, we can call public methods defined in Application Class or Current Activity.

Example:
if we define a method raiseToast in our android activity or Application class as:

    public void raiseToast(String message){
        Toast.makeText(this, message, Toast.LENGTH_LONG).show();
    }

then we can call this method from client as:
(ruby):

    @driver.execute_script("mobile: backdoor",[{name:"raiseToast",args:["Love Appium"]}])

This is not a very perfect code because of my lack of Java knowledge. However, this is working solution.

@dpgraham
Copy link
Contributor

I really like this.... I'll have a look at it.

Really cool feature though, I could see this having a lot of interesting use-cases.

Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool @rajdeepv! exciting to see the implementation of what you talked about at AppiumConf. Java's lack of metaprogramming makes this so much more difficult. I'm in favor of this idea, though we probably want a java person like @mykola-mokhnach to comment on the specifics of the code

@appium appium deleted a comment Dec 1, 2018
@appium appium deleted a comment Dec 1, 2018
@appium appium deleted a comment Dec 1, 2018
@appium appium deleted a comment Dec 1, 2018
Copy link
Contributor

@mykola-mokhnach mykola-mokhnach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy with the current implementation. Feel free to ask your boss about a promotion ;)

@rajdeepv
Copy link
Collaborator Author

rajdeepv commented Dec 1, 2018

He may fire me if sees this thread ;)

@appium appium deleted a comment Dec 1, 2018
@rajdeepv
Copy link
Collaborator Author

rajdeepv commented Dec 3, 2018

@mykola-mokhnach is there anything pending for this to merge?

@mykola-mokhnach
Copy link
Contributor

I wait for review from @dpgraham

Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to say thanks again @rajdeepv for this feature, it will be a lot of fun to release it to users and see how they make use of it!

Copy link
Contributor

@dpgraham dpgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see an E2E test for this, but I'll approve it and I can just write one.

@saikrishna321 Would you be able to help me with writing a test for this? I don't think it'll work with the APIDemos app but maybe we could test this on the VodQA app?

@dpgraham dpgraham merged commit 0e03d2c into appium:master Dec 3, 2018
@saikrishna321
Copy link
Member

@dpgraham Happy to help write a test for this. I don't think its possible to write with VodQA app as well because its build using ReactNative. @rajdeepv can we do with on RN apps as well?

@jlipps
Copy link
Member

jlipps commented Dec 3, 2018

@saikrishna321 nothing prevents you from writing some custom functions in the android code for your react native app, but it's probably difficult to do anything with the UI since that is all handled by RN

@saikrishna321
Copy link
Member

@jlipps should we build a sample native app to write an example test to show the superpower of backdoors?

@rajdeepv
Copy link
Collaborator Author

rajdeepv commented Dec 4, 2018

Hi @saikrishna321, I have no experience with RN apps. However just looked the code of vodqa app here https://github.com/appium/VodQAReactNative
If you put below code in VodQAReactNative/android/app/src/main/java/com/vodqareactnative/MainApplication.java

  public void raiseToast(String message){
    Toast.makeText(this, message, Toast.LENGTH_LONG).show();
  }

Then you can call it from the client as:
@driver.execute_script("mobile: backdoor", {:target=>"application", :methods=>[{:name=>"raiseToast", :args=>[{:value=>"Love Appium", :type=>"String"}]}]})

I did a quick trial and it worked for me. Need to check if we can do it in JS code

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

Successfully merging this pull request may close these issues.

None yet

6 participants