5
我上的Watir webdriver的工作的文本,我想要得到的页面使用的Watir-的webdriver:让h1标签
<body class="not-front not-logged-in page-node node-type-first-drive one-sidebar sidebar-right col-2 bp col-2 lightbox-processed" data-twttr-rendered="true">
<div class="container">
<div id="header">
<div class=""></div>
<div class="col-center">
<h1>New Page header</h1>
的h1标签的文本
,我写的代码是
@title2 = @browser.h1.attribute_value "text"
puts @title2
但我得到的输出,而不是“新页标题”无
感谢kinofrost,它这样工作,但只是想知道为什么ATTRIBUTE_VALUE是不是能够得到的文本。 – NewTester 2012-02-29 12:02:37
@NewTester因为attribute_value从DOM中的标签内拉取属性值。所以,你可以使用
标题
你可以使用browser.h1.attribute_value(:style)来获得“POSITION:relative”,但是text是一个watir-webdriver的方法,来自标签之间的文本。 – kinofrost 2012-02-29 14:31:11太棒了,明白了!谢谢Kinofrost – NewTester 2012-02-29 14:56:57