-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


Appium Essentials. 4

, 09 2017 . 17:58 +
. 4 Appium.
, 3 :

4.

Appium . , , uiautomator Appium inspector. web-, add-on Chrome, .

:
  1. Chrome ADB plugin
  2. Safari Develop
  3. UIAutomator Appium Inspector
  4. id, Name, LinkText, Xpath, cssSelector, ClassName, AccessibilityId, AndroidUIAutomator IosUIAutomation




Chrome ADB plugin


web-, add-on. Chrome ADB (add-on) [] . .
add-on, :
  1. [ ] Settings | About Phone Build number 7 (, Android 4.2 ). , Developer options:
    ( , How to enable developer options .)
  2. Developer options, ON ( ; OK); , - USB debugging :
  3. Chrome (, ADB ), ADB plugin , , View Inspection Targets:
  4. Android (, USB- ). , USB; OK.
  5. Chrome ( www.google.com).
  6. [ ] chrome://inspect/#devices . , Discover USB devices :
  7. inspect, ; . screencast, , :

iOS - Safari Develop


Safari , , :
  1. Settings | Safari | Advanced:
  2. Web Inspector:
  3. Safari .
  4. , Safari Mac, Develop, () (, Mac), URL:
  5. :

ID


-, . Appium client - -.
ID .
findElement(By.id(String id));

ID , . ID , Chrome ADB. Google:
  1. Chrome, www.google.com.
  2. ADB Inspect element.
  3. Google-, :

id -. :
WebElement searchBox=driver.findElement(By.id("lst-ib"));

, . , :
searchBox.sendKeys("Manoj Hans");

Safari iOS device. :
  1. Safari www.google.com.
  2. URL iOS Develop Safari Mac.
  3. Inspect, iOS , :


name


; :
findElement(By.name(String Name));

id, , . WebElement, . Google, , id, . , ID:

:
WebElement searchBox=driver.findElement(By.name("q"));


linkText


, . :
findElement(By.linkText(String text));

, . , WebElement.
Google, Images:
WebElement imagesLink=driver.findElement(By.linkText("Images"));


Xpath


Xpath XML HTML . , ID , , ID . Xpath, , Google. :
findElement(By.xpath(String XPath));

Xpath , . Xpath, :
WebElement searchBox=driver.findElement(By.xpath("//input[@id='lst-ib']"));


cssSelector


cssSelector HTML, Xpath. :
findElement(By.cssSelector(String cssSelector);

.
cssSelector Google:
WebElement searchBox=driver.findElement(By.cssSelector("#lst-ib"));




, UIAutomatorviewer ( Android) Appium Inspector. .

UIAutomatorviewer


UIAutomatorviewer Android SDK (C:\%android-sdk%\tools); Mac tools:

, :

Android:
  1. Android .
  2. .
  3. UIAutomatorviewer, . , UIAutomatorviewer .

, .

ID


, ID web-:
findElement(By.id(String id));

ID , . 5 UI Automator Viewer:
  1. UI Automator Viewer 5 .
  2. Node Details, resource-id com.android.calculator2:id/digit5:
  3. resource-id ID, :
    WebElement digit_5=driver.findElement(By.id("com.android.calculator2:id/digit5"));
  4. , :
    digit_5.click();


name


:
findElement(By.name(String Name));

, . DELETE:
  1. DELETE UI Automator Viewer.
  2. Node Details, text DELETE:
  3. DELETE, :
    delete.click();
      WebElement delete=driver.findElement(By.name("DELETE"));


className


:
findElement(By.className(String ClassName));

className:
  1. EditBox UI Automator Viewer.
  2. Node Detail, class android.widget.EditText:
  3. className:
    WebElement editBox=driver.findElement(By.className("android.widget.EditText"));
  4. EditBox, :
    editBox.getText();


, . , 7 :
List editBox=driver.findElements(By.className("android.widget.Button"));
  editBox.get(1).click();


findElements findElement; . , 7 1. , 1 .

AccessibilityId


Appium , AccessibilityId. , ID name. :
findElement(By.AccessibilityId(String AccId));

"+":
  1. UI Automator Viewer "+".
  2. Node Details, content-desc plus:
  3. content-desc AccId:
    WebElement plusSign=driver. findElementByAccessibilityId("plus");
              plusSign.click();


AndroidUIAutomator


AndroidUIAutomator . Android UIAutomator .
findElement(By.AndroidUIAutomator(String UIAuto));

"=":
  1. UI Automator Viewer "=".
  2. Node details . , resource-id com.android.calculator2:id/equal. resource-id UIAuto "=":
    WebElement equal=driver. findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.android.calculator2:id/equal\")";
  3. content-desc equals, :
    WebElement equal=driver. findElementBy.AndroidUIAutomator("new UiSelector().description(\"equals\")");

    , .


Appium Inspector


, Appium Inspector Mac. Mac, . Appium Inspector Android, :
  1. , Appium GUI . , .
    , ? APK Info Play Store. , Appium server .
  2. General Settings, Prelaunch Application.
  3. , Launch AVD Android Settings (, ). , USB debugging.
  4. .
  5. Inspector. Appium Inspector.

. Xpath

Xpath


:
findElement(By.xpath(String XPath));

9:
WebElement digit_9=driver.findElement(By.xpath("//android.widget.LinearLayout[1]/ android.widget.FrameLayout[1]/ android.widget.LinearLayout[1]/ android.support.v4.view.viewPager[1]/ android.widget.LinearLayout[1]/ android.widget.LinearLayout[1]/ android.widget.Button[3]"));


digit_9, .
, Appium Inspector iOS:
  1. Appium GUI .
  2. Prelaunch Application ( General Settings).
  3. , Force Device iOS Settings.
  4. .
  5. Inspector.

TestApp, Appium GitHub.

name


:
findElement(By.name(String Name));

EditBox TestApp:
  1. EditBox Appium Inspector.
  2. Details name IntegerB. EditBox:
    WebElement editBox=driver.findElement(By.name("IntegerB"));
  3. EditBox, :
    editBox.sendKeys("12");



IosUIAutomation


UIAutomation JavaScript , Apple's Automation Instruments. Appium Appium, IosUIAutomation:
findElements(By.IosUIAutomation(String IosUIAuto));

, IosUIAutomation, :
  1. IosUIAuto , . EditBox TestApp:
    WebElement editBox=driver. findElements(By.IosUIAutomation(".elements()[0]")); // '0' -   
  2. EditBox, :
    editBox.sendKeys("10");
  3. textFields:
    WebElement editBox=driver. findElements(By.IosUIAutomation(".textFields()[0]"));

UIAutomation, .


. . , Appium driver.
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/332706/

:  

: [1] []
 

:
: 

: ( )

:

  URL