. 4 Appium.
, 3 :
4.
Appium . , , uiautomator Appium inspector. web-, add-on Chrome, .
:
- Chrome ADB plugin
- Safari Develop
- UIAutomator Appium Inspector
- id, Name, LinkText, Xpath, cssSelector, ClassName, AccessibilityId, AndroidUIAutomator IosUIAutomation
Chrome ADB plugin
web-, add-on. Chrome ADB (add-on) [] .
.
add-on, :
- [ ] Settings | About Phone Build number 7 (, Android 4.2 ). , Developer options:
( , How to enable developer options .)

- Developer options, ON ( ; OK); , - USB debugging :

- Chrome (, ADB ), ADB plugin , , View Inspection Targets:

- Android (, USB- ). , USB; OK.
- Chrome ( www.google.com).
- [ ] chrome://inspect/#devices . , Discover USB devices :

- inspect, ; . screencast, , :

iOS - Safari Develop
Safari , , :
- Settings | Safari | Advanced:

- Web Inspector:

- Safari .
- , Safari Mac, Develop, () (, Mac), URL:

- :

ID
-, . Appium client - -.
ID .
findElement(By.id(String id));
ID , . ID , Chrome ADB. Google:
- Chrome, www.google.com.
- ADB Inspect element.
- Google-, :

id -. :
WebElement searchBox=driver.findElement(By.id("lst-ib"));
, . , :
searchBox.sendKeys("Manoj Hans");
Safari iOS device. :
- Safari www.google.com.
- URL iOS Develop Safari Mac.
- 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:
- Android .
- .
- UIAutomatorviewer, . , UIAutomatorviewer .

, .
ID
, ID web-:
findElement(By.id(String id));
ID , . 5 UI Automator Viewer:
- UI Automator Viewer 5 .
- Node Details, resource-id com.android.calculator2:id/digit5:

- resource-id ID, :
WebElement digit_5=driver.findElement(By.id("com.android.calculator2:id/digit5"));
- , :
digit_5.click();
name
:
findElement(By.name(String Name));
, . DELETE:
- DELETE UI Automator Viewer.
- Node Details, text DELETE:

- DELETE, :
delete.click();
WebElement delete=driver.findElement(By.name("DELETE"));
className
:
findElement(By.className(String ClassName));
className:
- EditBox UI Automator Viewer.
- Node Detail, class android.widget.EditText:

- className:
WebElement editBox=driver.findElement(By.className("android.widget.EditText"));
- 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));
"+":
- UI Automator Viewer "+".
- Node Details, content-desc plus:

- content-desc AccId:
WebElement plusSign=driver. findElementByAccessibilityId("plus");
plusSign.click();
AndroidUIAutomator
AndroidUIAutomator . Android UIAutomator .
findElement(By.AndroidUIAutomator(String UIAuto));
"=":
- UI Automator Viewer "=".
- Node details . , resource-id com.android.calculator2:id/equal. resource-id UIAuto "=":
WebElement equal=driver. findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.android.calculator2:id/equal\")";
- content-desc equals, :
WebElement equal=driver. findElementBy.AndroidUIAutomator("new UiSelector().description(\"equals\")");
, .
Appium Inspector
, Appium Inspector Mac. Mac, . Appium Inspector Android, :
- , Appium GUI . , .
, ? APK Info Play Store. , Appium server .
- General Settings, Prelaunch Application.
- , Launch AVD Android Settings (, ). , USB debugging.
- .
- 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:
- Appium GUI .
- Prelaunch Application ( General Settings).
- , Force Device iOS Settings.
- .
- Inspector.
TestApp,
Appium GitHub.
name
:
findElement(By.name(String Name));
EditBox TestApp:
- EditBox Appium Inspector.
- Details name IntegerB. EditBox:
WebElement editBox=driver.findElement(By.name("IntegerB"));
- EditBox, :
editBox.sendKeys("12");

IosUIAutomation
UIAutomation JavaScript , Apple's Automation Instruments. Appium Appium, IosUIAutomation:
findElements(By.IosUIAutomation(String IosUIAuto));
, IosUIAutomation, :
- IosUIAuto , . EditBox TestApp:
WebElement editBox=driver. findElements(By.IosUIAutomation(".elements()[0]")); // '0' -
- EditBox, :
editBox.sendKeys("10");
- textFields:
WebElement editBox=driver. findElements(By.IosUIAutomation(".textFields()[0]"));
UIAutomation,
.
. . , Appium driver.
https://habrahabr.ru/post/332706/