当前位置: 首页 > 知识库问答 >
问题:

Appium inspector在iOS中找不到日期选择器的xpath

张和颂
2023-03-14

嗨,我正在使用selenium尝试与我的iOS应用程序的日期选择器进行交互。然而,在appium inspector中,我无法看到xpath,甚至无法选择日期选择器与之交互。

我该如何与它互动。当我单击复制xml并将其粘贴到浏览器中时,我也不会在树中看到日期选择器。

编辑:添加在执行grid.driver().getPageSource()时出现的xml行,而不是仅仅从appium复制xml...我只看到添加到上面的是UIANavigationBar和UIAToolbar

        <UIAApplication name="myApp" label="myApp" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0" x="0" y="0" width="375" height="667">
    <UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0" x="0" y="0" width="375" height="667">
        <UIAStaticText name="Filter By Date" label="Filter By Date" value="Filter By Date" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/0" x="117" y="19.5" width="124.5" height="25">
        </UIAStaticText>
        <UIATableView name="FilterV-TableView-FilterOptions" label="" value="rows 1 to 5 of 5" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1" x="0" y="64" width="375" height="603">
            <UIATableCell name="ActivityVC-TableView-PredefinedFilterItem[0][0]" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0" x="0" y="27" width="375" height="55">
                <UIAStaticText name="ActivityVC-TableView-PredefinedFilterItem[0][0]" label="Past 90 Days " value="Past 90 Days " dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/1/0/0" x="18" y="45" width="87.5" height="19">
                </UIAStaticText>
            </UIATableCell>
            <UIATableCell name="ActivityVC-TableView-PredefinedFilterItem[0][1]" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1" x="0" y="82" width="375" height="55">
                <UIAStaticText name="ActivityVC-TableView-PredefinedFilterItem[0][1]" label="September " value="September " dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1/0" x="18" y="100" width="73" height="19">
                </UIAStaticText>
            </UIATableCell>
            <UIATableCell name="ActivityVC-TableView-PredefinedFilterItem[0][2]" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2" x="0" y="137" width="375" height="55">
                <UIAStaticText name="ActivityVC-TableView-PredefinedFilterItem[0][2]" label="2015 " value="2015 " dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2/0" x="18" y="155" width="35.5" height="19">
                </UIAStaticText>
            </UIATableCell>
            <UIATableCell name="ActivityVC-TableView-PredefinedFilterItem[0][3]" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/3" x="0" y="192" width="375" height="55">
                <UIAStaticText name="ActivityVC-TableView-PredefinedFilterItem[0][3]" label="2014 " value="2014 " dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/3/0" x="18" y="210" width="35.5" height="19">
                </UIAStaticText>
            </UIATableCell>
            <UIATableGroup name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/1/4" x="0" y="247" width="375" height="20">
            </UIATableGroup>
            <UIATableCell name="CUSTOM DATE RANGE" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/5" x="0" y="267" width="375" height="400">
                <UIAStaticText name="CUSTOM DATE RANGE" label="CUSTOM DATE RANGE" value="CUSTOM DATE RANGE" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/5/0" x="19" y="279" width="118" height="15">
                </UIAStaticText>
                <UIAStaticText name="From" label="From" value="From" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/5/1" x="18" y="318" width="28" height="15">
                </UIAStaticText>
                <UIAStaticText name="To" label="To" value="To" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/5/2" x="193" y="318" width="13" height="15">
                </UIAStaticText>
                <UIAButton name="FilterV-Button-FromDate" label="From" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/5/3" x="18" y="333" width="164" height="35">
                </UIAButton>
                <UIAButton name="FilterV-Button-ToDate" label="To" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/5/4" x="193" y="333" width="164" height="35">
                </UIAButton>
            </UIATableCell>
        </UIATableView>
        <UIAButton name="FilterV-Button-Cancel" label="Cancel" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/2" x="113.5" y="565" width="64" height="64">
        </UIAButton>
        <UIAButton name="FilterV-Button-Done" label="Done" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/3" x="197.5" y="565" width="64" height="64">
        </UIAButton>
        <UIANavigationBar name="myApp.ActivityFilterView" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/4" x="0" y="-44" width="375" height="44">
            <UIAImage name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/4/0" x="0" y="-64" width="375" height="64">
                <UIAImage name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/4/0/0" x="0" y="0" width="375" height="0">
                </UIAImage>
            </UIAImage>
            <UIAButton name="Back" label="Back" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/4/1" x="8" y="-35.5" width="24" height="24">
            </UIAButton>
        </UIANavigationBar>
        <UIAToolbar name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/5" x="0" y="667" width="375" height="44">
            <UIAImage name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/5/0" x="0" y="666.5" width="375" height="0.5">
            </UIAImage>
            <UIAImage name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/5/1" x="0" y="667" width="375" height="44">
            </UIAImage>
        </UIAToolbar>
    </UIAWindow>
    <UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/1" x="0" y="0" width="375" height="667">
    </UIAWindow>
    <UIAWindow name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/2" x="0" y="0" width="375" height="667">
        <UIAStatusBar name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/2/0" x="0" y="0" width="375" height="20">
            <UIAElement name="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" label="" value="" dom="" enabled="true" valid="true" visible="false" 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/2/0/0" x="6" y="0" width="38" height="20">
            </UIAElement>
            <UIAElement name="3 of 3 Wi-Fi bars" label="3 of 3 Wi-Fi bars" value="" dom="" enabled="true" valid="true" visible="false" 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/2/0/1" x="49" y="0" width="13" height="20">
            </UIAElement>
            <UIAElement name="3:17 PM" label="3:17 PM" value="" dom="" enabled="true" valid="true" visible="false" 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/2/0/2" x="165" y="0" width="45" height="20">
            </UIAElement>
            <UIAElement name="100% battery power" label="100% battery power" value="" dom="" enabled="true" valid="true" visible="false" 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/2/0/3" x="345" y="0" width="25" height="20">
            </UIAElement>
        </UIAStatusBar>
    </UIAWindow>
</UIAApplication>

共有1个答案

濮君植
2023-03-14

您可以与它交互,但问题只是Appium inspector没有显示它。如果从代码中打印使用driver.getPageSource()获得的XML树,就可以看到这些元素并在XPath中使用。至少我是这样为我的项目解决这个问题的。

 类似资料:
  • 我找不到日期选择器的元素。我尝试了CssSelector和xpath等。下面是我试过的代码。 代码: 下面是HTML代码。 HTML: 这里是错误: 组织。openqa。硒。NoTouchElementException:无法定位元素:

  • 本文向大家介绍iOS自定义日期选择器,包括了iOS自定义日期选择器的使用技巧和注意事项,需要的朋友参考一下 前言 封装了一个日期选择器,解决两个问题: 1、点击textField,键盘弹出和日期选择器弹出的逻辑处理; 2、同一个界面需要多次用到日期选择器时,判断点击的textField; 一、封装日期选择器类YCDatePickerView 1、新建一个类,基于UIView,取名YCDatePic

  • 我已经记录了用于从日期选择器中选择日期的selenium代码。在运行测试用例时,日期选择器会弹出并正确突出显示所选日期。但是没有选择日期。代码如下所示:- 此异常仅出现在记录的代码中。我使用的是selenium-server-standalone-2 . 45 . 0 jar。

  • 我试图在表中使用日期选取器添加和删除行。默认情况下,日期选取器不起作用。但是我点击了添加行按钮,它已经工作了。我找不到解决方案。 请参考小提琴位置。

  • HTML与它的外观截图一起粘贴,如下所示。 HTML: 我曾经试过 甚至试图等待命令以使定位器被找到但没有成功。 WebDriverWait(驱动程序,100)。直到(预期条件.element可禁用)(By.css选择器 两者都不起作用,因为它无法识别元素。有人能帮我吗。如果可能,我们甚至可以单击“上一个”和“下一个”,以便我们也可以单击一些以前的日期吗?

  • 问题内容: 在Android中使用日期选择器时选择错误的日期日期选择器对话框将日期选择为 2018/55/10 有时会选择正确的日期,但大多数情况下会选择错误的日期 问题答案: 您在日期格式中犯了一个常见错误:是分钟,用于获取月份。