我在 Firefox 浏览器中使用 watir
我正在寻找一种方法来单击不是链接的文本。我已经验证该文本存在于网站上,使用
b.text.include? "Tasks"
我尝试了几种不同的方法来单击此文本,但所有方法均不成功,到目前为止我已经尝试过
b.link(:text, "Tasks").click
b.text.click "Tasks"
b.text(:text, "Tasks").click
是否有一种方法可以使用 watir 单击此文本?任何帮助将非常感激
i am using watir in the firefox browser
I am looking for a way to click on text that is not a link. I have verified that the text exists on the website using
b.text.include? "Tasks"
I've tried several different ways to click on this text, but all have been unsuccessful, thus far i have tried
b.link(:text, "Tasks").click
b.text.click "Tasks"
b.text(:text, "Tasks").click
is there a way to click on this text using watir? any help would be greatly appreciated
如果点击这个不是链接的文本会导致某些事情发生,那么很可能有一个容器元素封装了文本,该文本被“连接”以在特定事件时执行某些特定的 JavaScript (如 onMouseDown 或 onClick)被检测到。根据开发人员设计页面的方式,可以使用大量元素类型(span、div、表格单元格等)。
由于可以嵌套多个容器(就像俄罗斯娃娃的极客版本),因此了解或弄清楚单击哪个容器将触发客户端代码非常重要。为此,您需要查看页面的 HTML 或使用开发人员工具(所有现代浏览器都有它们)来检查“可点击”文本附近的 DOM
。一般建议,我们需要查看页面该部分的 HTML,以便能够判断这是什么类型的元素,并建议正确的(如何、什么) 创建所需的值和元素类型单击元素或触发所需事件的代码行。
直到您可以提供额外的详细信息(编辑您的问题以添加信息)之前,您的问题以及答案都将受到 GIGO 综合症
If clicking on this text that is not a link causes something to happen, then it is likely that there is an container element that encapsulates the text which is 'wired' to execute some specific javascript when a particular event (like onMouseDown or onClick) is detected. A large number of element types are possible (span, div, table cell, just to name a few) depending on how the developer designed the page.
Since multiple containers can be nested (ala a geek version of Russian Dolls) it's important to know or figure out which one will trigger the client side code when it is clicked. To do this you need to look at the HTML for the page or use a developer tool (all modern browsers have them) to examine the DOM in the vicinity of the text that is 'clickable'
To give you a better answer that is anything but general advice, We Need To See The HTML for that part of the page in order to be able to tell what kind of element this is, and suggest the proper (how, what) values and element type that would be needed in order to create the line of code that would click on the element, or fire the needed event.
Until you can provide that additional detail (EDIT your question to add the information to it) your question and hence the answers as well, will all suffer from GIGO syndrome