Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7404059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:12:03+00:00 2026-05-29T05:12:03+00:00

I want to test is whether the table element exists? And if there is

  • 0

I want to test is whether the table element exists? And if there is no table then I just want the script to end. However if there is a table I want to output it to excel.

The script is testing two url’s:

http://www.mycounciltax.org.uk/results?postcode=EX99AE&search=Search

http://www.mycounciltax.org.uk/results?postcode=CV56bz&search=Search

The first url presents a web page without a html table and the second presents a web page which includes a html table element.

I have tried putting the following script together but I don’t think this is correct. I am sure I have made a mistake with testing the for the table element.

if browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}.exists?
then content = browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}

If you remove the above code from the below script it will run but will fall over when it doesn’t find the html table.

require "watir-webdriver"
browser = Watir::Browser.new :ff
browser.goto "http://www.mycounciltax.org.uk/results?postcode=CV56BZ&search=Search"

if browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}.exists?
then content = browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}
require 'win32ole'

application = WIN32OLE.new('Excel.Application')

application.visible = TRUE
workbook = application.Workbooks.Add();
worksheet = workbook.Worksheets(1);
worksheet.visible

row = 1; column = 0
content.each do |array|
array.each do |element|
worksheet.Cells(1,1).offset(row,column).value = element #.offset(row,column)
column += 1
end
row += 1
column = 0
end

else end

browser.goto "http://www.mycounciltax.org.uk/results?postcode=EX99AE&search=Search"

if browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}.exists?
then content = browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}
require 'win32ole'

application = WIN32OLE.new('Excel.Application')

application.visible = TRUE
workbook = application.Workbooks.Add();
worksheet = workbook.Worksheets(1);
worksheet.visible

row = 1; column = 0
content.each do |array|
array.each do |element|
worksheet.Cells(1,1).offset(row,column).value = element #.offset(row,column)
column += 1
end
row += 1
column = 0
end

else end

I plan to run the above code at once. Can anyone point out where I am going wrong? I am new to ruby and watir :-).

Many thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:12:04+00:00Added an answer on May 29, 2026 at 5:12 am

    There is an #exists? method.

    if browser.table.exists?
      # go on
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to test whether a request parameter is greater then 12 or not
I want to test whether Foo.app exists before I call: $ open -a Foo.app
I want to test whether a phone number is valid, and then translate it
Is there some equivalent of javascripts indexOf in Velocity? I want to test whether
I want to test whether a certain string is contained in a short list
I want to test whether two languages have a string in common. Both of
More specifically I want to test whether Oracle ODP.Net is installed on a machine.
I have a very simple question. I want to test whether a particular port
Writing some test scripts in IronPython, I want to verify whether a window is
We want test the JTAPI feature of our application. Are there any emulator for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.