element Positioning methodthe first one: through Appium1.6 's inspector to seespecific installation methods before the essay has been introduced:http://www.cnblogs.com/meitian/p/7360017.html element XPath or name can be found by locating personally do not recommend this method, the actual operation found that after each operation click Refresh is slow, and sometimes the left layout file update is not timely, resulting in clicking on the left-hand screen control can not find the element, and sometimes the app source is not updated The second type: positioning elements via Macaca app Inspector1. Installing Macaca-li
$ npm install macaca-cli -g
2. Check the Macaca environment
$ macaca doctor
as long as the printed results are green log information, it means that the environment is good 3. Installing App-inspector
$ npm install app-inspector -g
4. How to useStart the detection Web interface with the following command, and then automatically open "/http/local ip:5678" in Safari to detect
$ app-inspector -u YOUR-DEVICE-ID(设备id)
How iOS obtains the device ID:
$ xcrun simctl list
get the following data:The first parenthesis is the device ID of the phone, and the second parenthesis is the state of the emulator. as a result, you can also get the name and XPath of the element Description: I am currently using the second way, 1 is to directly refresh the page speed faster than Appium, 2 is not a great delay, after refreshing click on the element icon can generally find the element(also encountered a problem when the web opened, the phone interface at the bottom of the screen does not show the full, through the keyboard command and-number combination to reduce the page, showing the entire content) Note: App-inspector I use the simulator, with the real machine case has been an error. No problem with the simulator.error:connect econnrefused 127.0.0.1:8001At object.exports._errnoexception (util.js:1024:11)At Exports._exceptionwithhostport (util.js:1047:20)At Tcpconnectwrap.afterconnect [as OnComplete] (net.js:1150:14)
iOS action elementsThe XPath and name (or accessibility id) of the element can be obtained by the method above, and then the command corresponding to Appium is as follows:Accessibility ID or name: driver.find_element_by_name (
"name or accessibility id") driver.find_element (by.name,
"NAME or Accessibility id") XPath:Driver.find_element_by_xpath (
"XPath address")driver.find_element (By.xpath,
"XPATH address")
Appium1.6 locating iOS elements and manipulating elements