Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 支持 "elementByXPath" #36

Closed
codingfishman opened this issue Apr 27, 2016 · 8 comments
Closed

Android 支持 "elementByXPath" #36

codingfishman opened this issue Apr 27, 2016 · 8 comments
Assignees

Comments

@codingfishman
Copy link

  • Macaca Version:
 1.0.20
  • Macaca Doctor:
Node.js checklist:

  node env: /Users/fishman/.nvm/versions/node/v5.0.0/bin/node
  node version: v5.0.0

  iOS checklist:

  Xcode is installed at: `/Applications/Xcode.app/Contents/Developer`
  Xcode Command Line Tools is ready, version: 2343.
  ios_webkit_debug_proxy is installed at: /usr/local/bin/ios_webkit_debug_proxy

  Android checklist:

  JAVA version is `1.8.0_60`
  JAVA_HOME is set to `/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home`
  ANDROID_HOME is set to `/Users/fishman/Library/Android/sdk`
  • Platform:
Darwin fishmanadeMBP.lan 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_6

Hi There,
I tried to locate the element in Android with xpath but failed all the time. I got the xpath from Appium, something like : //android.widget.TextView[@text="消息"], and I tested in Appium it can get the target element.
But when I reach to macaca, the xpath doesn't work. If I tried to elementByClassName it will return all the elements, but for the QA guys, they are unable to find the target index of the element, as there could be a lot.

The xpath works fine with iOS app, maybe I made something wrong in android?

Thanks in advance!

@xudafeng
Copy link
Member

Android 暂不支持 xpath,可以先用 ByClass 吗?

@codingfishman
Copy link
Author

谢谢!是不是 elementByClassName? 如果是的话比较困难,因为同一个界面上有很多个同一类型的元素,而且有些元素是在其他元素之内的,在展开该元素之前还不知道有这个元素(借助appium获取type),因此比较难获取到index。 尝试了一下class嵌套,但是失败了。

@xudafeng
Copy link
Member

@codingfishman 能稍微描述下什么样的场景吗

@codingfishman
Copy link
Author

谢谢,好的。
其实是已经进入到APP的首页,需要点击底部的菜单再进入相应的面板。首页内容比较复杂,元素类型也有很多种(目前是这样的。。),通过elementByClassName会取到比较多的元素,不是像Demo中只有两个输入框。

底部的菜单栏最底层叫做android.widget.TextView, 再上一层是一个relativeLayout, 但这两个在页面上都是有不少个。TextView更多,在不同的元素嵌套下都有这个,所以elementByClassName以后不太好定位。后面如果开发在里面又加了新的TextView, 测试用例中的index也要更新。

我们主要是想把我们这个工具交给QA来使用,希望他们通过Appium能比较方便的找到对应元素的selector,也可以让测试代码更直观一些。所以如果能够支持 elementByXPath('//android.widget.TextView[@text="消息"]'), 那么将会很有帮助。

再次感谢!

@xudafeng
Copy link
Member

xudafeng commented Jul 4, 2016

@codingfishman 先用source-id 可以吗?elementById

@xudafeng xudafeng changed the title Failed to locate the element with "elementByXPath" for Android app Android 支持 "elementByXPath" Jul 4, 2016
@xudafeng
Copy link
Member

xudafeng commented Sep 7, 2016

@xudafeng
Copy link
Member

xudafeng commented Sep 7, 2016

@kobe990 xpath功能好了吗?

https://testerhome.com/topics/5883#reply5

@xudafeng xudafeng closed this as completed Sep 7, 2016
@xudafeng
Copy link
Member

xudafeng commented Sep 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants