Appium Python Tutorial - How to run Python Appium script in Real Android Device

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I welcome to the next video in the RPM Python series so we have been discussing different installation and setting up the emulator in Android studio in this video we're going to focus on three major topics number one how do we set up a real device number two or we can invoke an application through the RPM desktop client number three finally we'll see or we can run our fastest in the Regal device okay let's get started I'll show you that I've already connected an Android device but if I go and show it to you you should be timid with this command adb devices it doesn't it doesn't show up any any device attached to here because neither a emulator nor app phone right what I'm what we need to do is just go to mobile I'm going to show you from here you go to the mobile settings so generally you will find this option at the bottom of your screen then something called about phone if you click on it if you scroll at the bottom you will see something called bill number right so if you press this seven time or eight time we will be able to enable the developer option if I click it here this says that you are already a developer so if I go back here and then you will see something called developer options right so this is where we are enabling a debugging mode that means that our IBM can interact with the real device right but it does it doesn't stop there we need to be enabling one more thing somebody called USB debugging so this we are running the app in the debug mode that's when we are able to interact with it so if you enable this one it'll prompt you with a pop-up say that click OK and the moment you've complete come back now check that whether you are able to see the attached device if I execute the same command now you are now seeing that there is a device attached to this my computer right and sometimes you may see that there is an unauthorized thing I was told in my previous video if we get this in the emulator you need to go and do a swipe data swipe data in the understood you but in the real device you can do it through just go back to the developer option and you need to revoke the USB authorization and then try killing the server and start the server so a couple of server commands then you need to just go and then adb you know the comment a DB start server as the server has already started they need to stop you need to kill and stop right because in my case it is already connected it doesn't show me that there is a authorize to another race to problem so that's why I'm this proceeding with it now ok so this is how you can make your phone interact with your happy M client right now the real device setup is done that's our part one a enabling the developer option now we also know how to enable and revoke the USB debugging so if you enable it they will be able to interact with the mobile if you haven't cared of unauthorized error then just go revoke the I USB debugging option and then come back and start and stop your server sorry stop and star start your server right ok the next that we gonna see he is to invoke an app in the real device the way we have done in emulated we will do the same thing in from the appium server so if I click on the PM desktop I need to open it I'm going to start the server remember that this is a port number it's surrounding so if you start the server and this is the interface and we are going to do the start inspector session right if you click on it and we have seen what are the different available desired capabilities these are the capabilities that we have seen it already so one more capability of this village for the real device so with this now I am just putting a very minimal thing in this time I'm going to I'm going install and Flipkart application on my mobile so the path of the application is here this is the download part and the device name is something that name that they got from here it's not then untried emulator it's is the device number device name that you need to paste it yet right the device name is clear platform is clear and app is clear now right but remember that we had two more additional capabilities that's nothing but a package and a wave activity that you can do once you have the app in your mobile right okay so big this come on now I'm this course start my session and then see whether we are able to see that starting it in the mobile this session right the moment to start IBM servers also get started and now you see that and keep an eye on the lock because that will give you whether it is successful or failure and this time yes we are able to invoke the application in our mobile now right this is the application I want to draw it again from this point we need to just identify the element and then start interacting with it okay our second part is done so we now know how to invoke a real application and an application the real device right let's move on to the our third part third part is nothing but invoking the same test from our Python right how do we do that there are a couple of things we need to do before it because as we know any language definitely it requires the dependencies to be downloaded like Java we have a form that XML which downloads all of the dependencies she having to do the same thing so how do we do that you remember our initial video there is a pip comment it's a pip package manager for Python which downloads all the packages right so we need to just go command-line if I go to the project this is a project we have created and if I go to virtual environment I would hold you what is the word surrender when virtual environment it is basically a and I saluted environment from a different project right where we can keep all the different version of the software whatever we need so if we go under the library and cite packages so these are all the packages available at the moment well we don't see any dependency for a p.m. right how do we get started so there are two ways you can do that one the easiest way in through the UI you can just go to file settings project interpreter and you see something called the plus symbol here right the moment you click here these are the available packages in this project the project called IBM sandbox right if we click on the plus symbol it's going to give up this UI and if you type IPM and this is going to give you different options the option that we are going to see now here IBM Python client this client in includes all of the IBM files as well as selenium so basically selenium is a wrapper around sorry IPM is a wrapper around selenium will get all the complete packets okay so this is the one way you can do it other way you can do the same thing through going to this script folder and then find it in the park to an explorer and if you open a command prompt from here right and you need to move to the script folder basically so CD use typescript you will get this option and from here you know to just do the same thing pip install so where do I get the package name so if you google you and you put all right so this is the complete package index for the entire Python language right so you can find whatever you need I'm searching for the RPM one the moment you select and you will be given a lot of options the Dobson that we are looking at here is the AB p.m. Python client this one 0.36 okay these are all very specific library because this one comprises of everything so we have this going to select this one and you see that this this is a common problem so we just copy this one that means a deep install IBM Python client so the moment you go there and you can just put the comment here and then install it discipline this will install all the required packages and if we now go to the project and it will see now in the side packages now you see all the packages are uploaded now right that means that we need we have way of downloaded all the required dependencies right from this point onwards we'll be able to interact with any of the object or properties from the RPM so let's get let's create a sample Python file let me name this as first tensed okay so this like any other language like for example if you come from Java don't you know that we need to import it right that's our first statement so you import he quill the same keyword here but little different there are three ways we can import it there we can directly import it or we can just say from this folder imported or import as example so the there are three options we're going to see that in the future videos but for now what we need to import it we need to go to library side packages this appium under this RPM we have something called web driver so we need this driver and if you go because in python the way it understands in Python I will give you a little more or no tips how we can interact with it for example if it's directly type import web driver it doesn't give me an option at all because it can't find the web driver directly so the interpreter doesn't find the web driver directly we can confirm it if we go to the settings again and if we go to the project interpreter and you click this gear icon and if you show all and you say the last option here like something like hierarchy and this queues we're a second [Music] if you click on this option this is where the interpreter look for everything below right so became something called library side packages and this are all pipe and specific thing and there is a virtual environment folder also there and there is something called Lib site packages and psych packages tool so anything below this parent folder and the interpreter will be able to import it but our package is under the sites packages under a p.m. right so we can directly import webdriver that's the reason so anything below site packages will be able to interact with this so that's where we are using the from command here so we put because anything below site packages we interpret the rest visibility what is there in there right so from if we say at p.m. and then import webdriver right because under they are p.m. you have two things right you go here there is something called common and something called webdriver that's where we are interested in and we know that it is using the same travel protocol that's where we are used we are getting the webdriver thing okay so but you are seeing an underline because we have not used this anywhere in our code we are going to use it now okay so like in selenium so we need to create a desired capability so the word rubber parameter that we have passed in in our inspector here we need to pass the same thing to the script that's why we will be able to create a driver object so the way we can do it because remember it is a key value pair and Python we have something called dictionary which is nothing but the same key value pair we going to create a dictionary so let's say desired cap equal to this is the decorated for dictionary right so I'm going to copy paste all of the values that we have here because it's already there in the dictionary format you can copy all of this let me copy from here and then here hope I can put all of the well so they easy this the shortcut to clean up if you are using up by charming windows just control all control a and control art I will do the intention indentation right okay so now we know that desired capabilities there is a there is a dictionary which is called a desire capability and from here we need to just : try invoke a driver so this like selenium equal to do the same thing right so now we have imported a webdriver webdriver is nothing but a folder here right so if it's a webdriver dot there is a remote class there you see that select the remote class it just like the baby are invoking a grid in selenium right so if you don't know what to be given and for the input the parameter or arguments and just do ctrl Q this is going to tell you what you need to be providing it expects self that's fine we will discuss more about what is self in the pizza video but now we need to provide a command executor of this kind right this is nothing but the babe can find out this connection detail will be go to the easiest to be you can get this from is this way right so this is this this is the connection you so we need to give this connection first as a first parameter within double code or single code that's fine and we need to also up in this width if we just put control Q again this is going to give you the format WD and iPhone right that's webdriver dot hug web driver hub okay no we know that because it's running on the port it's listening on the port 4-7 two three that's why we are specifying but in here it by default they say four four four four yeah that's not where our IBM client is running so in the next parameter that we need to provide is the desired capabilities object that we created the dictionary object right will be provided here that's all I mean Python there is no semicolon here it's pretty simple plain language but it maintains the indentation so you need to be clear about the hierarchy we'll be seeing in the future video but for now it is done so if I create from here the driver object will be created I'm going to say this as a driver that's fine and I'm this going to be leaving it here so make this few lines of code now we are able to do the same thing what we have done in here right we'll be able to do the same thing but here remember that this server has to be still running we can't ignore it but instead of going to the inspector and start the session this time we are gonna do this from the Python so let's then and keep an eye on the mobile whether we are able to invoke it and we also be looking at the logs right click on it or just go here and then run the first driver list and if you look at the device and console also carefully okay there is another it says that can't open the file [Music] okay let me run it again first test there may be some configuration thing and if you go keep an eye on the device and also the logs yes so we are now he built we are now able to invoke the same application through our Python so this is our fastest and definitely we're gonna see whatever what are our different locating strategies hold we can locate the element like selenium what are the different methods are available and how we can you know do a real Reagle test using the real object and then now we can navigate what are the different mobile specific action that we will be I mean that we'll be looking at in the future videos if you have any question comments just put it in the comment section and if you have if you like the video please subscribe thanks for watching
Info
Channel: Cope Automation
Views: 52,160
Rating: undefined out of 5
Keywords: Appium Python, Python Appium, Appium, Appium turorial for beginners, Appium Beginner tutorials, Appium python tutorials for beginners
Id: seolp-8oxHM
Channel Id: undefined
Length: 18min 28sec (1108 seconds)
Published: Sat Jan 26 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.