簡體   English   中英

Appium錯誤處理不起作用

[英]Appium error handling doesn't work

我是新手,所以可能做錯了。

我在使用wdio和茉莉花的appium時遇到問題

it('wtf', (done) => {
  client.init().element('someName').getText()
//                       ^ here was a mistake
    .then(result => result, err => {
//                          ^ this error handling wasn't work  
  throw new Error(`Cannot get text of element: #someName\n${err}`);
  })
    .then(text => expect(text).toBe('correct'))
    .then(done)
});

appium服務器日志告訴我:

[HTTP] --> POST /wd/hub/session/63aa60d2-9638-4b1a-a226-cfbb2fcfce2c/element {"using":"css selector","value":"someName"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["css selector","someName","63aa60d2-9638-4b1a-a226-cfbb2fcfce2c"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[HTTP] <-- POST /wd/hub/session/63aa60d2-9638-4b1a-a226-cfbb2fcfce2c/element 500 4 ms - 152 
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"platformName":"android","app":"./app-dev-debug.apk","appPackage":"com.#####.dev.debug","appActivity":"com.#####.feature.start.StartActivity","avdReadyTimeout":1000,"udid":"LGK350RGNBS4TS","deviceName":"LG-K350","clearSystemFiles":true,"fullReset":true,"newCommandTimeout":120,"requestOrigins":{"url":"http://webdriver.io","version":"4.12.0","name":"webdriverio"}}}

但是jsmine卡住了,沒有拋出錯誤,日志:

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

Stack:
  Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)

“完成”不是承諾

配置的茉莉花超時= 300000

主要問題:茉莉花為什么沒有收到引發的異常?

找到解決方案(虛擬修復):

使用功能:

testMobile = <T>(promise: Client<T>, done: () => void): Client<void> =>
promise.then(done, err => {
    expect(err).toBe('Ok');
    done();
});

並使用:

it('wtf', done =>
  testMobile(client.init()
    .element('someName').getText()
    .then(result => result, err => {  
      throw new Error(`Cannot get text of element: #someName\n${err}`);
     })
     .then(text => expect(text).toBe('correct')),
  done)
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM