TESTEVERYTHING

Showing posts with label android automation. Show all posts
Showing posts with label android automation. Show all posts

Thursday, 13 July 2017

Handle custom tags using WebDriver

Sometime while doing automation we have to identify the element which have custom tags like <g> <svg> etc. For this we normally use * that will identify all elements tags in case we have to identify only specified custom tag then we can use below example for this.


<svg height="600" width="910" xmlns:xlink="http://www.w3.org/1999/xlink"  
   id="svgcontent" overflow="visible" x="910" y="600" viewBox="0 0 910 600">
    <g style="pointer-events:all">
      <text fill="rgb(0,0,0)" font-family="Sans-Serif" font-size="13" id="80-155-126" 
        transform="rotate(-90, 168, 126)" y="126" x="168" style="pointer-
         events:inherit">A100A</text>
   </g>
  </svg>

Following Xpath will work here

By.xpath("//*[local-name()='svg']")

By.xpath("//*[local-name()='text']")


By.xpath("//*[local-name()='g']")


Tuesday, 4 August 2015

How to use ADB (Android Debug Bridge) over WiFi | Android automation

Whenever we work with Android mobile app automation we have to connect the device using USB cable. We can connect the device over Wi-Fi. To get rid of from the USB there is a super simple way! All you need is a USB cable (for the initial setup) and have both devices in the same network. This will work for non-rooted devices also.

Precondition: 
  • Your system and device must be in the same network.
  • Android mobile must have developer option set to true.
  • ADB (Android debug bridge) must be configure
  • Android SDK installed.
Step 1. Attach mobile via USB

Step 2. Open then command terminal type adb devices and press enter

It will confirm that your device is connected and able to recognize by android sdk.




Step 3:   type:
adb tcpip 5555
Step 4:To find the mobile ip type:
adb shell ip -f inet addr show wlan0
Step 5: The ip address will be shown in second line like this:
inet 192.168.1.233/24 brd 192.168.1.255 scope global wlan0
where 192.168.1.233 is the ip address of your mobile.
Step 6:Remove USB cable and type:
   adb connect <mobile-ip>:5555

 like:
adb connect <192.168.1.233>:5555 

Note: 
  1. Make sure: that you do not have Android studio running before executing the - 'restart adb in tcpip mode' command
  2. If you have IDE running then adb may have been already started and you may need to restart it in some cases: adb kill-server; adb start-server

Saturday, 25 July 2015

How to know app package and activities information without having apk | android app | Appium

How to know app package and activities information without having apk | android app | Appium

In Android app mobile automation,we need apk file of app but sometimes we have to perform action on inbuild app(pre installed) which come with device like call,sms etc.. for this we do not have apk file. Basically in android app automation we need app package information  and app activities. In case of apk it is easy to get above information with appium. But if we do not have apk and need the app package/activities information, we can use following command:

Precondition: 
1. Android mobile must have developer option set to true.
2. ADB (Android debug bridge) must be configure
3. Android SDK installed.

Step1. Open then command terminal type adb devices and press enter

It will confirm that your device is connected and able to recognize by android sdk.






Step2: Now in mobile, open the app of which you want to get app pkg info/activities. In your mobile, it should be current activated app with focus. Means current window of your mobile should be app like calling/msg/your app window. 

Step3: Now type adb shell and press enter to open the adb shell

Step4: type dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'  and press enter







Above command will show the current activated app info of  your mobile. Now check the value of mCurrentFocus.

First highlighted text is pkg info



Second highlighted text is app activities info


Here you can see that we can use this:





 Thanks



Which one is right ?

Translate







Tweet