The code in the line 277 is puts @browser.text_field(:id => "street").html. I try this code:
puts @browser.execute_script('return document.getElementById("street")[0]').html but the error says: Error: test_login(TC_Login) : NoMethodError: undefined method `html' for nil:NilClass excel.rb:275:in `test_login' and I also try this one: puts @browser.execute_script('return document.getElementById("street")[0]').innerHTML and the error was: Error: test_login(TC_Login) : NoMethodError: undefined method `innerHTML' for nil:NilClass excel.rb:275:in `test_login' but if I use puts @browser.execute_script('return document.getElementsByClassName("sample_class")[0]').html it works.. it display the html tags... On Tuesday, February 17, 2015 at 2:31:04 PM UTC+8, Nice Faith wrote: > > Hai Guys. I am just trying to explore or learn Watir. > I have already try this one: > > puts browser.text > and it works. I would like to ask if it is possible to display or print > only the specific element or html tags. > For example this one: > > <button class="btn btn-add" data-role="add">Add New User</button> > Is there any way to get this element only? Not the whole Page source. > > -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.