如何在GEB中找到包含特定字符串的行,并在该特定行中选择一个链接/复选框 [英] How to find the row that contains a specific string in GEB and in that particular row I need to select a link/checkbox

查看:171
本文介绍了如何在GEB中找到包含特定字符串的行,并在该特定行中选择一个链接/复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以找到包含GEB中特定字符串的行号/索引?我可以检查一行是否包含特定的字符串或不包含:

Is there any way to find the row number/index that contains a specific string in GEB? I can check whether a row contains a specific string or not with:

text: contains()

但是,如何找到该行的索引,然后使用该索引ID单击同一行中的链接?任何建议或帮助将非常感激。请不要说我到目前为止尝试了什么。我已经花了几个小时了,但仍然没有办法!

But how can I find the index of that row and then click on a link in the same row using that index ID? Any suggestion or help would be really appreciated. Please don't say what did I try so far. I spent few hours already and still no way!

编辑:好的,问题是:我可以选择具有已知索引的任何行,例如:

Okay, so the problem was: I can select any row with known index, for instance:

$('p', 1).click() 

但是当我不知道行的索引,并且在特定的行中,我需要选择一个链接/复选框,我相信这是一种方式我们想要处理这个问题,不是吗?或者有没有其他更好的方法可以做到这一点?

but when I don't know the index of the row and in that particular row I need to select a link/checkbox, I believe this is the way we want to handle the issue, isn't it? Or is there any other better way to do it?

推荐答案

您必须按行查找链接指数?如果它在同一行上,为什么不按照你的建议找到使用的行,包含,然后访问它的父级,然后重新找回链接?

Must you find the link by row index? If it's on the same row, why not find the row using contains as you suggested, then access its parent, then dive back in to find the link?

例如 $('p',包含('some text'))。parent()。find( 链接 ) .click();

如果这不起作用,你能解释为什么你需要在这样的庄园中访问它吗?

If that won't work, could you explain why you need to access it in such a manor?

这篇关于如何在GEB中找到包含特定字符串的行,并在该特定行中选择一个链接/复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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