Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Watir-webdriver : Getting the text of h1 tag

I am working on Watir webdriver and I want to get text of the h1 tag of the page

<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>

The code that I am writing is

@title2 = @browser.h1.attribute_value "text"
    puts @title2

BUT the output that I am getting is Nil instead of "New Page header"

like image 821
NewTester Avatar asked Feb 29 '12 09:02

NewTester


1 Answers

Have you tried

puts @browser.h1.text

or

puts @browser.div(:class => 'col-center').h1.text
like image 100
kinofrost Avatar answered Oct 12 '22 09:10

kinofrost