Appium- IOS点击某元素不生效

appium Desktop版本是1.18.3最新的版本,IOS版本是13.1.2
这个元素是截图里面标红的元素,是可以点击的,不是每次点击都失败,有点击成功过的时候


IOS界面进行UI自动化测试,元素找到了,但是点击的时候不生效
appium对应报错:

[HTTP] <-- POST /wd/hub/session/ecca6a39-edca-422b-a761-1663af20e972/element/49000000-0000-0000-2008-000000000000/click 200 3844 ms - 76
[HTTP] 
[HTTP] --> GET /wd/hub/session/ecca6a39-edca-422b-a761-1663af20e972/contexts
[HTTP] {}
[MJSONWP (ecca6a39)] Calling AppiumDriver.getContexts() with args: ["ecca6a39-edca-422b-a761-1663af20e972"]
[XCUITest] Executing command 'getContexts'
[XCUITest] Getting list of available contexts
[iOS] Retrieving contexts and views
[XCUITest] Cannot enter web frame without a bundle ID
[MJSONWP (ecca6a39)] Encountered internal error running command: Error: Cannot enter web frame without a bundle ID
[MJSONWP (ecca6a39)]     at Object.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-support/lib/logging.js:94:35)
[MJSONWP (ecca6a39)]     at XCUITestDriver.listWebFrames (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/context.js:194:9)
[MJSONWP (ecca6a39)]     at XCUITestDriver.getContextsAndViews (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/appium-ios-driver/lib/commands/context.js:160:29)
[MJSONWP (ecca6a39)]     at XCUITestDriver.getContexts (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/context.js:247:31)
[MJSONWP (ecca6a39)]     at commandExecutor (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/appium-base-driver/lib/basedriver/driver.js:334:9)
[MJSONWP (ecca6a39)]     at /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/async-lock/lib/index.js:125:12
[MJSONWP (ecca6a39)]     at AsyncLock._promiseTry (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/async-lock/lib/index.js:249:31)
[MJSONWP (ecca6a39)]     at exec (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/async-lock/lib/index.js:124:9)
[MJSONWP (ecca6a39)]     at AsyncLock.acquire (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/async-lock/lib/index.js:140:3)
[MJSONWP (ecca6a39)]     at XCUITestDriver.executeCommand (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/appium-base-driver/lib/basedriver/driver.js:347:39)
[MJSONWP (ecca6a39)]     at XCUITestDriver.executeCommand (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:714:24)
[MJSONWP (ecca6a39)]     at AppiumDriver.executeCommand (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/lib/appium.js:534:36)
[MJSONWP (ecca6a39)]     at runMicrotasks ()
[MJSONWP (ecca6a39)]     at processTicksAndRejections (internal/process/task_queues.js:85:5)
[MJSONWP (ecca6a39)]     at asyncHandler (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:297:21)
[HTTP] <-- GET /wd/hub/session/ecca6a39-edca-422b-a761-1663af20e972/contexts 500 6 ms - 213
[HTTP] 
[HTTP] --> GET /wd/hub/session/ecca6a39-edca-422b-a761-1663af20e972/source

对应步骤加上对应sleep(2)还是不能点击~

1、帖子要发在答疑区哈
2、发下代码,定位表达式看看

from time import sleep
from appium import webdriver

def initIOSDriver():
    print("进入app初始化")
    caps ={
      "platformName": "iOS",
      "deviceName": "iPhonex",
      "appPackage": "com.igetcool.app",
      "noReset": True,
      "platformVersion": "",
      "udid": "",
      "automationName": "XCUITest",
      "enableWebviewDetailsCollection": True,
      "autoGrantPermissions": True,
      "unicodeKeyboard": True,
      "resetKeyboard": True,
      "newCommandTimeout": 3600,
      "useNewWDA": False,
      "wdaLocalPort": 8200
    }
    driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
    
    sleep(5)
 driver.find_element_by_xpath('//XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther').click()
    sleep(2)
    driver.find_element_by_xpath('//XCUIElementTypeSearchField').send_keys("随便写一写")
    sleep(2)
    driver.find_element_by_accessibility_id('清除文本').click()


  

initIOSDriver()

简单写了下启动的代码

对应的清除文本元素无法点击

启动参数不对

{
"platformName": "ios",
"bundleId": "xx.xxx.xx",
"automationName": "XCUITest",
"deviceName": "iPhone",
"udid": "auto",
"xcodeOrgId": "7******S",
"xcodeSigningId": "iPhone Developer"

}

参考下这个帖子

http://appium.io/docs/en/writing-running-appium/caps/#ios-only

platformName : iOS
platformVersion: “”
udid: ‘’
deviceName: ‘’
restart: true
app: com.igetcool.app
automationName: ‘XCUITest’
noReset: True
enableWebviewDetailsCollection: True
autoGrantPermissions: True
unicodeKeyboard: True
resetKeyboard: True
newCommandTimeout: 3600
useNewWDA: True
wdaLocalPort: 8300

哪个参数不对啊,下面是全的参数

这个appium报错也不是因为启动参数报错呀,要是启动参数报错的原因,那么前面两个步骤就不应该进行,启动app以后就会报错,但是目前是,在点击清除这个元素的时候报错,并且不是每次都报错,有正确通过的时候,但不是那么稳定,所以,找到这个报错信息想问下怎么提高对应的稳定性

报错就是bundleId的问题,你改下试试

启动参数改了以后app启动都起不来了。。

bundle ID 对吗

bundle ID就是app对应的那个参数吧,就是安装软件的

这个包名吧

启动起来了

还是报错

[Xcode]     t =    30.14s Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    30.32s Find: Descendants matching type Any
[Xcode] 
[Xcode]     t =    30.32s Find: Elements matching predicate 'wdName == "清除文本" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeerValue == 0 OR selected == 0)'
[Xcode] 
[Xcode]     t =    30.33s Find: Identity Binding
[Xcode] 
[Xcode]     t =    30.34s Tap "清除文本" Button
[Xcode] 
[Xcode]     t =    30.34s     Wait for com.igetcool.app to idle
[Xcode] 
[Xcode]     t =    30.34s     Find the "清除文本" Button
[Xcode] 
[Xcode]     t =    30.34s         Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    30.50s         Find: Descendants matching type Any
[Xcode] 
[Xcode]     t =    30.50s         Find: Elements matching predicate 'wdName == "清除文本" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 laceholderValue == 0 OR selected == 0)'
[Xcode] 
[Xcode]     t =    30.50s         Find: Identity Binding
[Xcode] 
[Xcode]     t =    30.51s     Check for interrupting elements affecting "清除文本" Button
[Xcode] 
[Xcode]     t =    30.52s         Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    30.61s         Find: Descendants matching predicate identifier == "NotificationShortLookView" OR elementType == 7
[Xcode] 
[Xcode]     t =    30.62s     Synthesize event
[Xcode] 
[Xcode]     t =    30.66s         Scroll element to visible
[Xcode] 
[Xcode]     t =    30.66s         Failed: Failed to scroll to visible (by AX action) Button, {{273.7, 55.7}, {24.0, 24.0}}, label: '清除文本', error: Error kAXErrorCannotComplete performing AXAction 2003 on elemen element pid: 425, elementOrHash.elementID: 4843786592.282
[Xcode] 
[Xcode]     t =    31.67s     Retrying `Tap "清除文本" Button` (attempt #2)
[Xcode] 
[Xcode]     t =    31.67s         Wait for com.igetcool.app to idle
[Xcode] 
[Xcode]     t =    31.69s         Find the "清除文本" Button
[Xcode] 
[Xcode]     t =    31.69s             Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    31.87s             Find: Descendants matching type Any
[Xcode] 
[Xcode]     t =    31.88s             Find: Elements matching predicate 'wdName == "清除文本" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled =OR placeholderValue == 0 OR selected == 0)'
[Xcode] 
[Xcode]     t =    31.88s             Find: Identity Binding
[Xcode] 
[Xcode]     t =    31.89s         Check for interrupting elements affecting "清除文本" Button
[Xcode] 
[Xcode]     t =    31.90s             Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    32.01s             Find: Descendants matching predicate identifier == "NotificationShortLookView" OR elementType == 7
[Xcode] 
[Xcode]     t =    32.02s         Synthesize event
[Xcode] 
[Xcode]     t =    32.05s             Scroll element to visible
[Xcode] 
[Xcode]     t =    32.06s             Failed: Failed to scroll to visible (by AX action) Button, {{273.7, 55.7}, {24.0, 24.0}}, label: '清除文本', error: Error kAXErrorCannotComplete performing AXAction 2003 on elt AX element pid: 425, elementOrHash.elementID: 4843786592.282
[Xcode] 
[Xcode]     t =    33.07s     Retrying `Tap "清除文本" Button` (attempt #3)
[Xcode] 
[Xcode]     t =    33.07s         Wait for com.igetcool.app to idle
[Xcode] 
[Xcode]     t =    33.09s         Find the "清除文本" Button
[Xcode] 
[Xcode]     t =    33.10s             Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    33.27s             Find: Descendants matching type Any
[Xcode] 
[Xcode]     t =    33.27s             Find: Elements matching predicate 'wdName == "清除文本" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled =OR placeholderValue == 0 OR selected == 0)'
[Xcode] 
[Xcode]     t =    33.28s             Find: Identity Binding
[Xcode] 
[Xcode]     t =    33.28s         Check for interrupting elements affecting "清除文本" Button
[Xcode] 
[Xcode]     t =    33.29s             Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    33.39s             Find: Descendants matching predicate identifier == "NotificationShortLookView" OR elementType == 7
[Xcode] 
[Xcode]     t =    33.40s         Synthesize event
[Xcode] 
[Xcode]     t =    33.43s             Scroll element to visible
[Xcode] 
[Xcode]     t =    33.44s             Failed: Failed to scroll to visible (by AX action) Button, {{273.7, 55.7}, {24.0, 24.0}}, label: '清除文本', error: Error kAXErrorCannotComplete performing AXAction 2003 on elt AX element pid: 425, elementOrHash.elementID: 4843786592.282
[Xcode] 
[Xcode] 2020-12-05 17:33:10.215990+0800 WebDriverAgentRunner-Runner[422:34906] Enqueue Failure: Failed to synthesize event: Failed to scroll to visible (by AX action) Button, {{273.7, 55.7}, {24.0, 24.0}}, label: '清除文本', error: Error kAXErrorCannotComplete performing AXAction 2003 on element AX element pid: 425, elementOrHash.elementID: 4843786592.282. (Underlying Error: Error kAXErrorCannotComplete performing AXAction3 on element AX element pid: 425, elementOrHash.elementID: 4843786592.282) /usr/local/lib/node_modules/appium/node_modules/_appium-webdriveragent@2.31.0@appium-webdriveragent/WebDriverAgentRunner/UITestingUITests.m 39 1
[Xcode] 

发下报错信息

[Xcode] 2020-12-05 17:33:10.215990+0800 WebDriverAgentRunner-Runner[422:34906] Enqueue Failure: Failed to synthesize event: Failed to scroll to visible (by AX action) Button, {{273.7, 55.7}, {24.0, 24.0}}, label: ‘清除文本’, error: Error kAXErrorCannotComplete performing AXAction 2003 on element AX element pid: 425, elementOrHash.elementID: 4843786592.282. (Underlying Error: Error kAXErrorCannotComplete performing AXAction3 on element AX element pid: 425, elementOrHash.elementID: 4843786592.282) /usr/local/lib/node_modules/appium/node_modules/_appium-webdriveragent@2.31.0@appium-webdriveragent/WebDriverAgentRunner/UITestingUITests.m 39 1

你这个报错是你执行滑动操作失败了

1 个赞

明明是click为什么底层执行了滑动

[2020-12-05 17:33:06,749] [logging:log_info] [INFO]- click:清除文本,0
[2020-12-05 17:33:06,750] [logging:log_info] [INFO]- [HTTP] --> POST /wd/hub/session/d81a67ee-d36b-404d-96d7-73002acf39f0/element/1A010000-0000-0000-A901-000000000000/click
[2020-12-05 17:33:06,751] [logging:log_info] [INFO]- [HTTP] {"id":"1A010000-0000-0000-A901-000000000000"}
[2020-12-05 17:33:06,751] [logging:log_info] [INFO]- [W3C (d81a67ee)] Driver proxy active, passing request on via HTTP proxy
[Xcode]     t =    30.14s Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    30.32s Find: Descendants matching type Any
[Xcode] 
[Xcode]     t =    30.32s Find: Elements matching predicate 'wdName == "清除文本" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeerValue == 0 OR selected == 0)'
[Xcode] 
[Xcode]     t =    30.33s Find: Identity Binding
[Xcode] 
[Xcode]     t =    30.34s Tap "清除文本" Button
[Xcode] 
[Xcode]     t =    30.34s     Wait for com.igetcool.app to idle
[Xcode] 
[Xcode]     t =    30.34s     Find the "清除文本" Button
[Xcode] 
[Xcode]     t =    30.34s         Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    30.50s         Find: Descendants matching type Any
[Xcode] 
[Xcode]     t =    30.50s         Find: Elements matching predicate 'wdName == "清除文本" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 laceholderValue == 0 OR selected == 0)'
[Xcode] 
[Xcode]     t =    30.50s         Find: Identity Binding
[Xcode] 
[Xcode]     t =    30.51s     Check for interrupting elements affecting "清除文本" Button
[Xcode] 
[Xcode]     t =    30.52s         Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    30.61s         Find: Descendants matching predicate identifier == "NotificationShortLookView" OR elementType == 7
[Xcode] 
[Xcode]     t =    30.62s     Synthesize event
[Xcode] 
[Xcode]     t =    30.66s         Scroll element to visible
[Xcode] 
[Xcode]     t =    30.66s         Failed: Failed to scroll to visible (by AX action) Button, {{273.7, 55.7}, {24.0, 24.0}}, label: '清除文本', error: Error kAXErrorCannotComplete performing AXAction 2003 on elemen element pid: 425, elementOrHash.elementID: 4843786592.282
[Xcode] 
[Xcode]     t =    31.67s     Retrying `Tap "清除文本" Button` (attempt #2)
[Xcode] 
[Xcode]     t =    31.67s         Wait for com.igetcool.app to idle
[Xcode] 
[Xcode]     t =    31.69s         Find the "清除文本" Button
[Xcode] 
[Xcode]     t =    31.69s             Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    31.87s             Find: Descendants matching type Any
[Xcode] 
[Xcode]     t =    31.88s             Find: Elements matching predicate 'wdName == "清除文本" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled =OR placeholderValue == 0 OR selected == 0)'
[Xcode] 
[Xcode]     t =    31.88s             Find: Identity Binding
[Xcode] 
[Xcode]     t =    31.89s         Check for interrupting elements affecting "清除文本" Button
[Xcode] 
[Xcode]     t =    31.90s             Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    32.01s             Find: Descendants matching predicate identifier == "NotificationShortLookView" OR elementType == 7
[Xcode] 
[Xcode]     t =    32.02s         Synthesize event
[Xcode] 
[Xcode]     t =    32.05s             Scroll element to visible
[Xcode] 
[Xcode]     t =    32.06s             Failed: Failed to scroll to visible (by AX action) Button, {{273.7, 55.7}, {24.0, 24.0}}, label: '清除文本', error: Error kAXErrorCannotComplete performing AXAction 2003 on elt AX element pid: 425, elementOrHash.elementID: 4843786592.282
[Xcode] 
[Xcode]     t =    33.07s     Retrying `Tap "清除文本" Button` (attempt #3)
[Xcode] 
[Xcode]     t =    33.07s         Wait for com.igetcool.app to idle
[Xcode] 
[Xcode]     t =    33.09s         Find the "清除文本" Button
[Xcode] 
[Xcode]     t =    33.10s             Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    33.27s             Find: Descendants matching type Any
[Xcode] 
[Xcode]     t =    33.27s             Find: Elements matching predicate 'wdName == "清除文本" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled =OR placeholderValue == 0 OR selected == 0)'
[Xcode] 
[Xcode]     t =    33.28s             Find: Identity Binding
[Xcode] 
[Xcode]     t =    33.28s         Check for interrupting elements affecting "清除文本" Button
[Xcode] 
[Xcode]     t =    33.29s             Requesting snapshot of accessibility hierarchy for app with pid 425
[Xcode] 
[Xcode]     t =    33.39s             Find: Descendants matching predicate identifier == "NotificationShortLookView" OR elementType == 7
[Xcode] 
[Xcode]     t =    33.40s         Synthesize event
[Xcode] 
[Xcode]     t =    33.43s             Scroll element to visible
[Xcode] 
[Xcode]     t =    33.44s             Failed: Failed to scroll to visible (by AX action) Button, {{273.7, 55.7}, {24.0, 24.0}}, label: '清除文本', error: Error kAXErrorCannotComplete performing AXAction 2003 on elt AX element pid: 425, elementOrHash.elementID: 4843786592.282
[Xcode] 
[Xcode] 2020-12-05 17:33:10.215990+0800 WebDriverAgentRunner-Runner[422:34906] Enqueue Failure: Failed to synthesize event: Failed to scroll to visible (by AX action) Button, {{273.7, 55.7}, {24.0, 24.0}}, label: '清除文本', error: Error kAXErrorCannotComplete performing AXAction 2003 on element AX element pid: 425, elementOrHash.elementID: 4843786592.282. (Underlying Error: Error kAXErrorCannotComplete performing AXAction3 on element AX element pid: 425, elementOrHash.elementID: 4843786592.282) /usr/local/lib/node_modules/appium/node_modules/_appium-webdriveragent@2.31.0@appium-webdriveragent/WebDriverAgentRunner/UITestingUITests.m 39 1
[Xcode] 

发下代码看看