首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UI自动化:导出元素树

UI自动化:导出元素树
EN

Stack Overflow用户
提问于 2014-02-27 10:21:30
回答 2查看 766关注 0票数 0

在UI自动化中,是否有一种方法可以将logElementTree()生成的元素树以不同于默认格式的格式导出(例如,XML)。我想在UI自动化之外使用元素层次结构。

我已经在一个测试脚本中使用logElementTree()记录了树,它成功了,在编辑器日志中显示为“通过”。我尝试过“导出跟踪结果”,但这似乎没有起到作用。

EN

回答 2

Stack Overflow用户

发布于 2015-02-25 09:21:04

您可以使用Appium检查器来获得XML结果:Appium

Appium是一个开源的自动化框架。它还提供了获取应用程序UI层次结构的工具。

按照说明操作并启动Appium检查器。填写所需信息,如设备类型和UDID。截图:Appium Inspector

使用Appium GUI,在右下角有一个“复制XML”按钮。按刷新按钮以获取当前屏幕的UI层次结构。

这是计算器应用程序的结果。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<AppiumAUT>
    <UIAApplication name="Calculator" label="Calculator" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0" x="0" y="20" width="320" height="548">
        <UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0" x="0" y="0" width="320" height="568">
            <UIAStaticText name="Result" label="Result" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/0" x="0" y="0" width="320" height="168">
            </UIAStaticText>
            <UIAButton name="all clear" label="all clear" value="all clear" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1" x="1.5" y="169.5" width="78.5" height="79">
            </UIAButton>
            <UIAButton name="plus, minus" label="plus, minus" value="plus, minus" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/2" x="80.5" y="169.5" width="79" height="79">
            </UIAButton>
            <UIAButton name="percent" label="percent" value="percent" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/3" x="160" y="169.5" width="79" height="79">
            </UIAButton>
            <UIAButton name="divide" label="divide" value="divide" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/4" x="239.5" y="169.5" width="79" height="79">
            </UIAButton>
            <UIAButton name="7" label="7" value="7" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/5" x="1.5" y="249" width="78.5" height="79">
            </UIAButton>
            <UIAButton name="8" label="8" value="8" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/6" x="80.5" y="249" width="79" height="79">
            </UIAButton>
            <UIAButton name="9" label="9" value="9" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/7" x="160" y="249" width="79" height="79">
            </UIAButton>
            <UIAButton name="multiply" label="multiply" value="multiply" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/8" x="239.5" y="249" width="79" height="79">
            </UIAButton>
            <UIAButton name="4" label="4" value="4" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/9" x="1.5" y="328.5" width="78.5" height="79">
            </UIAButton>
            <UIAButton name="5" label="5" value="5" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/10" x="80.5" y="328.5" width="79" height="79">
            </UIAButton>
            <UIAButton name="6" label="6" value="6" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/11" x="160" y="328.5" width="79" height="79">
            </UIAButton>
            <UIAButton name="subtract" label="subtract" value="subtract" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/12" x="239.5" y="328.5" width="79" height="79">
            </UIAButton>
            <UIAButton name="1" label="1" value="1" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/13" x="1.5" y="408" width="78.5" height="79">
            </UIAButton>
            <UIAButton name="2" label="2" value="2" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/14" x="80.5" y="408" width="79" height="79">
            </UIAButton>
            <UIAButton name="3" label="3" value="3" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/15" x="160" y="408" width="79" height="79">
            </UIAButton>
            <UIAButton name="add" label="add" value="add" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/16" x="239.5" y="408" width="79" height="79">
            </UIAButton>
            <UIAButton name="0" label="0" value="0" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/17" x="1.5" y="487.5" width="157" height="79">
            </UIAButton>
            <UIAButton name="decimal" label="decimal" value="decimal" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/18" x="160" y="487.5" width="79" height="79">
            </UIAButton>
            <UIAButton name="equals" label="equals" value="equals" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/19" x="239.5" y="487.5" width="79" height="79">
            </UIAButton>
        </UIAWindow>
        <UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1" x="0" y="0" width="320" height="568">
            <UIAStatusBar name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/1/0" x="0" y="0" width="320" height="20">
                <UIAElement name="2 of 5 bars, signal strength" label="2 of 5 bars, signal strength" value="" dom="" enabled="true" valid="true" visible="true" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top" path="/0/1/0/0" x="6" y="0" width="35" height="20">
                </UIAElement>
                <UIAElement name="T-Mobile network" label="T-Mobile network" value="" dom="" enabled="true" valid="true" visible="true" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top" path="/0/1/0/1" x="44" y="0" width="48" height="20">
                </UIAElement>
                <UIAElement name="3 of 3 Wi-Fi bars" label="3 of 3 Wi-Fi bars" value="FireEye" dom="" enabled="true" valid="true" visible="true" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top" path="/0/1/0/2" x="97" y="0" width="13" height="20">
                </UIAElement>
                <UIAElement name="10:48 AM" label="10:48 AM" value="" dom="" enabled="true" valid="true" visible="true" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top" path="/0/1/0/3" x="134" y="0" width="52" height="20">
                </UIAElement>
                <UIAElement name="95% battery power, Charging" label="95% battery power, Charging" value="" dom="" enabled="true" valid="true" visible="true" hint="Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top" path="/0/1/0/4" x="282" y="0" width="33" height="20">
                </UIAElement>
            </UIAStatusBar>
        </UIAWindow>
    </UIAApplication>
</AppiumAUT>
票数 1
EN

Stack Overflow用户

发布于 2014-07-24 01:36:13

http://www.w3schools.com/xsl/xsl_transformation.asp

像上面这样的东西会起作用吗?

例如,类似这样的代码将把测试结果大致解析成一个HTML表:

代码语言:javascript
复制
<table border="1" style="width:800px">
                    <tr>
                    <th>Timestammp</th>
                    <th>Sequence</th>
                    <th>Message</th>
                    <th>Type</th>
                    <th>Screenshot</th>
                    </tr>
<xsl:for-each select="plist/dict/array/dict">
                        <tr>
                            <td>
                                <xsl:value-of select="translate(translate(date, 'T',' '), 'Z','')"/>
                            </td>
                            <td><xsl:value-of select="position()"/></td>
                            <td><xsl:value-of select="string"/></td>
                            <td>
                                <xsl:choose>
                                    <xsl:when test="integer = 8"><span style="color:blue">Screenshot</span></xsl:when>
                                    <xsl:when test="integer = 5"><span style="color:green">Pass</span></xsl:when>
                                    <xsl:when test="integer = 4"><span style="color:orange">Message</span></xsl:when>
                                    <xsl:otherwise><xsl:value-of select="integer"/></xsl:otherwise>
                                </xsl:choose>
                            </td>
                            <td>
                                <xsl:if test="integer = 8">
                                    <xsl:element name="img">
                                        <xsl:attribute name="src"><xsl:value-of select="string"/>.png</xsl:attribute>
                                        <xsl:attribute name="style">height:250px;width:167px;</xsl:attribute>
                                    </xsl:element>
                                </xsl:if>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>

顺便说一句,我已经有一段时间没有使用它了,因为我还没有到我的项目的那个阶段,我相信大部分都来自于某人的博客。如果我可以再次找到该网站,我会张贴它的信用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22057782

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档