????Appium??????Webdriver?????λ?????????
????find by "tag name" (i.e.?? ???UI????????)
????find by "name" (i.e.?? ???????????? ????? ?????????????id????? ????accessibilityIdentifier)
????find by "xpath" (i.e.?? ????????????·?????????? ????XPath???)
????###????????????
????????????UIAutomation?????????????????? ??????ü?????? ????ο???????????
????https://github.com/appium/appium/blob/master/lib/uiauto/lib/mechanic.js#L29
????(????????????)
????????Android?μ???????? ????ο?
????https://github.com/appium/appium/blob/master/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/AndroidElementClassMap.java
????????
???????????????е?UIAButtons
????WD.js:
driver.elementsByTagName('button'?? function(err?? buttons) {
// tap all the buttons
var tapNextButton = function() {
var button = buttons.shift();
if (typeof button !== "undefined") {
button.click(function(err) {
tapNextButton();
})
} else {
driver.quit();
}
}
tapNextButton();
});
Ruby:
buttons = @driver.find_elements :tag_name?? :button
buttons.each { |b| b.click }
Python:
[button.click() for button in driver.find_elements_by_tag_name('button')]
??????????????????(????accessibilityIdentifier)?"Go"?????
????WD.js:
????driver.elementByName('Go'?? function(err?? el) {
????el.tap(function(err) {
????driver.quit();
????});
????});
????Ruby:
????@driver.find_element(:name?? 'Go').click
????Python:
????driver.find_element_by_name('Go').click()
?????????"Hi?? "?????????????
????WD.js:
????driver.elementByXpath('//navigationBar/text[contains(@value?? "Hi?? ")]'?? function(err?? el) {
????el.text(function(err?? text) {
????console.log(text);
????driver.quit();
????});
????});
????Ruby:
????@driver.find_element :xpath?? '//navigationBar/text[contains(@value?? "Hi?? ")]'
???????tagName???????
????Java:
????driver.findElement(By.tagName("button")).sendKeys("Hi");
????WebELement element = findElement(By.tagName("button"));
????element.sendKeys("Hi");
????List<WebElement> elems = findElements(By.tagName("button"));
????elems.get(0).sendKeys("Hi");
????Python:
????driver.find_elements_by_tag_name('tableCell')[5].click()
????FindAndAct<a name="findandact"></a>
?????????????????????????????????????(???????IOS)
???????????? ??????????ε????????????????????????? ??????????mobile: findAndAct
????Python:
????args = {'strategy': 'tag_name'?? 'selector': 'button'?? 'action': 'tap'}
????driver.execute_script("mobile: findAndAct"?? args)
???????????????????????????
????Python:
????js_snippet = "mobile: swipe"
????args = {'startX':0.5?? 'startY':0.2?? 'startX':0.5?? 'startY':0.95?? 'tapCount':1?? 'duration':10}
????driver.execute_script(js_snippet?? args)
???????: driver.execute_script() ?????? Automating Mobile Gestures: Alternative access method) ??????
???????Appium Inspector????λ???
????(?????: ????????????Mac?汾?? ???????????windows?? ???????android?????traceview?????????????λ??)
????Appium??????????????Appium Inspector?? ????????app???е???? ????λ?????????????. ???Appium Inspector(????start test?????i??????)?? ????????????????????????????????name????? ?????????UI?????????ж?λ