考虑条件下很少的参数,在ios布局选项卡上执行单击操作

时间:2019-06-24 17:46:41

标签: java selenium mobile appium ios-ui-automation

我想单击typeOther后面紧跟的typeCell元素,它在name属性中具有日期,我正在编写此代码 列出elementCells;

如何使用列表存储和检查元素值,并根据条件匹配,我应该能够单击具有日期或某些文本的TypeOther元素的下一个同级兄弟(它将始终是),但是我需要在其中查找日期,今天或昨天等模式

我在手机上有这样的脚本

<XCUIElementTypeTable>
<XCUIElementTypeOther>
<XCUIElementTypeOther>
<XCUIElementTypeOther name="PENDING">
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeOther name="May 21, 2019">
<XCUIElementTypeOther>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeOther name="Mar 1, 2019">
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>
<XCUIElementTypeCell>

List<MobileElement> elementCells ;

    if(b==true) {
        elementCells =   
 getDriver().findElements(by("collect_elements_cells"));
        label(String.valueOf(elementCells.size()));

        Iterator<MobileElement> iterator = 
 elementCells.iterator();
        int index=0;
        while (iterator.hasNext()) {

             MobileElement option = 
 getDriver().findElement(by("elements_cells"));
             MobileElement strname = iterator.next();
            System.out.println(option.getText());
            index++;

        }

    //  //if(elementCells.size()>1)
    //  //scroll(elementCells.get(1));
        MobileElement option = 
getDriver().findElement(by("elements_cells"));
    //  scroll(option);
        hardWait(2000);
        option.click();

其中的xpath     collect_elements_cells = xpath | // *。[@ name ='CNBMobile.AccountDetailsView'] /以下:: XCUIElementTypeTable / XCUIElementTypeOther [@name]

elements_cells = xpath | //*[@name='CNBMobile.AccountDetailsView']/following::XCUIElementTypeTable/XCUIElementTypeOther[@name][2]/following-sibling::XCUIElementTypeCell[1]/XCUIElementTypeStaticText[@name][1]

如果TypeOther有日期,如何匹配,所以单击jst nxt元素单元格

0 个答案:

没有答案