Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: watir webdriver print the count of a list item

user2240134:

i am new to Watir and having some problem getting the Count of a list item in a web page and outputting this out. i have tried the following


office_lists = browser_driver.li(:class, 'office')
office_list = browser_driver.li(:class, 'office')

office_list = Hash.new 0
office_list.links.each do |link|
office_list[link] += 1
puts office_list

but i have been unsuccessful with this. I was hoping someone could. Say these are all my li on the page









  • i would then like to put this in some sort of an array object, then get the count and the output the number of items like so


    puts "There are #{count} number of offices in the list"

    Any help would be much appreciated. also do i need to require anything such as "pp" or "p" or anything else or will Watir be enough for this task?

    Many thanks,



    Posted in S.E.F
    via StackOverflow & StackExchange Atomic Web Robots
    This Question have been answered
    HERE


    This post first appeared on Stack Solved, please read the originial post: here

    Share the post

    SOLVED: watir webdriver print the count of a list item

    ×

    Subscribe to Stack Solved

    Get updates delivered right to your inbox!

    Thank you for your subscription

    ×