使用 Ruby 实现自动化问题

发布于 2024-12-08 23:28:16 字数 1713 浏览 0 评论 0原文

我是 Ruby 的初学者,在使用 Ruby 和 Watir 进行自动化测试时遇到一些问题。我的问题是我无法访问网页中的文本字段 'id= namecolumnbeginswith' 和 'name=ProjectsList_namecolumnbeginswith_0'

我尝试了这个:

ie.text_field(:name, "ProjectsList_namecolumnbeginswith_0").set("gapc")

然后

ie.hidden(:xpath, "//input[ @id='namecolumnbeginswith' @title='Search By Name'  @name='ProjectsList_namecolumnbeginswith_0' @iniValue='Starts With' @prompt='Starts With' @value='Starts With']/").set("gapc")

然后

ie.frame(:name, "FRAME").frame(:name, "nested_frame").text_field(:name, "ProjectsList_namecolumnbeginswith_0").set("gapc")

然后

ie.link(:href, "/pwcollab/wdk/theme/documentum/css/dragdrop.css").click

然后

ie.link(:class, "projectsList").click

然后

ie.frame(:name,"FRAME").frame(:name,"nested_frame").button(:value,"ProjectsList_OK_0").click

所有这些命令都不起作用

这个网页被引用:

    '</script>'
</head>
<frameset onload="onLoad()" rows="100%,*" border="0">
    <frame title="Frame for system use" src="/pwcollab/wdk/blank.htm" noresize />
    <frame title="Frame for system use" src="/pwcollab/wdk/blank.htm" />
</frameset>
</html>

我使用 watir 来查找我的框架并通过 IRB 得到了这个结果:

irb(main):048:0> ie.show_frames

有0 帧

=> 0..-1

然后我尝试使用 DOM 访问文本字段

Ie.div(:class) 尝试所有类我总是遇到这个错误

Watir::Exception::UnknownObjectException: Unable to locate element

总结一下我需要一些使用 Ruby 和 Ruby 访问网页中的文本字段的建议Watir 用于自动化 Web 应用程序测试。

I am a beginer with Ruby and I have some issue using Ruby and Watir to automate tests. My problem is I cant reach text field in web page with
‘id= namecolumnbeginswith’ and ‘name=ProjectsList_namecolumnbeginswith_0’

i tried this :

ie.text_field(:name, "ProjectsList_namecolumnbeginswith_0").set("gapc")

then

ie.hidden(:xpath, "//input[ @id='namecolumnbeginswith' @title='Search By Name'  @name='ProjectsList_namecolumnbeginswith_0' @iniValue='Starts With' @prompt='Starts With' @value='Starts With']/").set("gapc")

then

ie.frame(:name, "FRAME").frame(:name, "nested_frame").text_field(:name, "ProjectsList_namecolumnbeginswith_0").set("gapc")

then

ie.link(:href, "/pwcollab/wdk/theme/documentum/css/dragdrop.css").click

then

ie.link(:class, "projectsList").click

then

ie.frame(:name,"FRAME").frame(:name,"nested_frame").button(:value,"ProjectsList_OK_0").click

no one of all this commands works

This web page is referenced by :

    '</script>'
</head>
<frameset onload="onLoad()" rows="100%,*" border="0">
    <frame title="Frame for system use" src="/pwcollab/wdk/blank.htm" noresize />
    <frame title="Frame for system use" src="/pwcollab/wdk/blank.htm" />
</frameset>
</html>

I use watir to find my frames and got this result with IRB :

irb(main):048:0> ie.show_frames

there are 0 frames

=> 0..-1

Then I tried to DOM to access to the text field using

Ie.div(:class)trying all classes I always have this error

Watir::Exception::UnknownObjectException: Unable to locate element

To summarize I need some advices to access a text field in a web page using Ruby & Watir to automate web application test.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹊巢 2024-12-15 23:28:16

我们需要更多信息才能告诉您问题可能出在哪里(除了键盘后面的螺母松动之外;-)我自己和其他 watir 用户会很乐意提供帮助,但您不会回复评论(编辑问题)没有足够的资源供我们工作。

具体来说,为了告诉您可能出了什么问题,我们至少需要两件事之一。

1) 网页“源”代码,其中定义了您尝试与之交互的元素。您尝试与之交互的页面元素都不存在于您所包含的一小段 HTML 中。甚至您尝试使用“嵌套框架”的框架也不会出现在其中,因此不幸的是,在向我们提供帮助您所需的信息时,这一点 HTML 完全毫无用处。

2)具体错误。 “所有这些命令都不起作用”传达的有用信息为零。如果我们可以看到从您尝试过的各种操作中返回的特定错误,那么我们就可以更深入地了解某些东西不工作的具体方式和原因,并且了解错误的根本原因可能能够告诉我们您需要做什么才能让您的代码正常工作。

最后一点建议,您可以为您尝试处理的元素之一提供一个 ID 值。如果一个项目有一个 ID,因为根据 HTML 标准,ID 在页面中应该是唯一的,因此仅凭 ID 就足以识别该元素。此时添加类、名称或任何其他属性都是多余的。

We need more information to be able to tell you where the problem might be (aside from a loose nut behind the keyboard ;-) Myself and other watir users would be glad to offer assistance but without your responding to the comments (edit the question) there's not enough for us to work from.

Specifically in order to tell you what might be wrong we would need at the very least one of two things.

1) web page 'source' code where the element you are trying to interact with is defined. None of the page elements you are trying to interact with are present in the small bit of HTML that you included. Not even the frame you try to use 'nested frame' appears in there, so unfortunately that little bit of HTML is completely utterly useless when it comes to giving us the info we need to assist you.

2) Specific errors. "no one of all this commands works" communicates zero useful information. If we can see the specific error that is being returned from the various things you have tried, then we have a little more insight into exactly HOW and WHY something is not working, and knowing the underlying cause of the error might potentially be able to tell you what you need to do to get your code working.

Lastly just a bit of advice, You give an ID value for one of the elements you are trying to address. If an item has an ID, since by HTML standards ID's are supposed to be unique within the page, that alone should suffice to identify the element. Adding in class, name or any other attribute would be redundant at that point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文