
我捡主要的将。java代码:
package comibmtest;
import javaioFile;
import comandroiduiautomatorcoreUiDevice;
import comandroiduiautomatorcoreUiObjectNotFoundException;
import comandroiduiautomatortestrunnerUiAutomatorTestCase;
public class MyUIauto extends UiAutomatorTestCase {
private static final String TAG = "MyUIauto";
public void testPressHome() throws UiObjectNotFoundException {
File file = new File("/data/local/tmp/local/tmp/qianxml");
UiDevice uiDevice = getUiDevice();
//uiDevicepressHome();
String realPath = "qianxml";
uiDevicedumpWindowHierarchy(realPath);
}
}
String xpath = "/html/body/form/div/table/a";
List<Node> trNodes = docselectNodes(xpath);
for (int i=1;i < trNodessize();i++){
Element trElement = (Element)trNodesget(i);
List<Element> tdList = trElementelements();
Element tdElement1 = tdListget(1);
Element fontElement1 = (Element)tdElement1elements()get(0);
String c1 = fontElement1getText()
}
可以试试
C# code
private void FormBrower_Load(object sender, EventArgs e)
{
webBrowserNavigate(">
爬虫跟踪下一页的方法是自己模拟点击下一页连接,然后发出新的请求。请看: item1 = Item()yield item1item2 = Item()yield item2req = Request(url='下一页的链接', callback=selfparse)yield req 注意使用yield时不要用return语句。
$('#id')siblings() 当前元素所有的兄弟节点
$('#id')prev() 当前元素前一个兄弟节点
$('#id')prevaAll() 当前元素之前所有的兄弟节点
$('#id')next() 当前元素之后第一个兄弟节点
$('#id')nextAll() 当前元素之后所有的兄弟节点
这三个方法都可以添加选择器,给出选择条件,就能找到你指定的兄弟节点了。
selxpath() 得到的依旧是一个SelectorList
参看原文档
xpath(query)
Find nodes matching the xpath query and return the result as a SelectorList instance with all elements flattened List elements implement Selector interface too
query is a string containing the XPATH query to apply
那么实际上就是去看Selector 相关的函数了。
————————————————
<p>
AA
<sub>1</sub>
<sub>2</sub>
<sub>3</sub>
</p>
<p>
BB
<sub>1</sub>
<sub>2</sub>
<sub>3</sub>
</p>
对于上述例子,其实可以考虑获取到p之后,对其内容再进行一次查找,即可获得 1 、2 、3的内容。
xpath_input_exp_mark = '//label[contains(text(), "文本内容")]//following-sibling::div[1]//input'
browserfind_element_by_xpath(xpath_input_exp_mark)
表示当前节点的父节点
following-sibling::div[1] 表示当前节点的 兄弟节点 中的 第 1 个 div 标签
以上就是关于uiautomatorviewer怎么获取xpath全部的内容,包括:uiautomatorviewer怎么获取xpath、Xpath 怎么获取元素节点的名字、WebBrowser浏览器控件,怎么获取页面某网页元素XPATH等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)