正文

查看html中frame的源代码2007-03-20 16:29:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/daweizhao/24135.html

分享到:

ruby写测试脚本,目前还只是停留在照猫画虎的阶段,发觉目前两个语句有帮助。

  $ie.text_field(:name, "password").set('zhaodw123')
  $ie.button(:value, "登 录").click

但是如果是frame的话,网页代码显示如下:

<HTML>
<HEAD>
<TITLE>自助系统ver2.6 </TITLE>
</HEAD>
<FRAMESET COLS="212,*" FRAMEBORDER="0" rows="*">
 <FRAME SRC="tree.htm" SCROLLING="yes" name="left">
     <FRAME SRC="inform/info.htm" SCROLLING="yes" name="right">
  </FRAMESET><noframes>你的浏览器不支持FRAME!</noframes>
</HTML>             找不到源代码

在网上查,有人说要把SRC的内容补充到地址栏即可,试了一下,对是对的,但是显示的不是我要的网页。后来,在右键-->在新窗口中打开处解决了:这样的话打开的是一个没有frame框架的html网页,可在下就可以查看源代码了。

$ie.frame("right").text_field(:name , "operLogName").set('patient123')
  $ie.frame("right").button(:value,"下一步").click

但是接下来,又出现了问题:如果不是test_field和button而是有超链接的图片,要怎么做?用link方法:


       ie.link(:url, /login/)              # access the first link whose url mat
ches login. We can use a string in place of the regular expression
                                           # but the complete path must be used,
 ie.link(:url, 'http://myserver.com/my_path/login.asp')
       ie.link(:index,2)                   # access the second link on the page
       ie.link(:title, "Picture")         # access a link using the tool tip
       ie.link(:text, 'Click Me')          # access the link that has Click Me a
s its text
       ie.link(:afterText, 'Click->')      # access the link that immediately fo
llows the text Click->
       ie.link(:xpath, "//a[contains(.,'Click Me')]/")      # access the link wi
th Click Me as its text
用的是   ie.link(:index,2)   ,之前没也用,是担心不知道index,后来才知道这里的index指的是link的第几个,而不包含其它的index。仔细看文档,也是有说明的。今后要仔细看文档。

问题总是有解决方法的。在想是不是毕设也用ruby做。

查找方法说明进:只要在DOS状态下,ri命令即可,如:ri link

但是也可以进入C下的ruby路径下:C:\ruby\lib\ruby\gems\1.8\gems\watir-1.5.1.1158\doc>index.html,可以直接找到网页,来查找

阅读(4678) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册