如何使用webdriverIO搜索网格中的特定按钮 [英] How to search an specific button in a grid using webdriverIO

查看:228
本文介绍了如何使用webdriverIO搜索网格中的特定按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

解决方案

在不知道你正在使用哪个定位器的情况下,很难知道如何做,但是如果您首先获取行列表,然后过滤它们并抓住它应该的第一个匹配做你想要的。

  public static get rows(){return browser.elements('#someTableId> table> ; tbody> tr'); } 

public static getFirstMatch(){
return this.rows.value.filter((row:WebdriverIO.Element)=>
browser.elementIdElement(row.ELEMENT, 'someLocator')值)[0];
}


I'm using an ExtJS grid panel. This grid has more than 20 rows of info and I want to search in each row for an icon that represents active mode, using WebdriverIO as a test driver.

How can I search in each row till the test driver finds the first active icon? (Note: the grid I'm testing is hosted on alegra.com).

Consider the following HTML print-screen:

解决方案

It's hard to know exactly how to do it without knowing which locator you are using but if you first get a list of the rows and then filter them and grab the first match it should do what you are looking for.

public static get rows() { return browser.elements('#someTableId > table > tbody > tr'); }

public static getFirstMatch() {
    return this.rows.value.filter((row: WebdriverIO.Element) =>
        browser.elementIdElement(row.ELEMENT, 'someLocator').value)[0];
}

这篇关于如何使用webdriverIO搜索网格中的特定按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆