lundi 13 mars 2017

watir - ruby code " undefined method present? pr exist"

require 'rubygems' require "watir"

    browser = Watir::Browser.new :chrome,:switches => %w[--disable-notifications]
    i=0;
    begin

    #TODO logining to the facebook
    browser.goto 'linkedin.com'
    browser.text_field(:id => 'login-email').set 'ananthragavendra@gmail.com'
    browser.text_field(:id => 'login-password').set 'ru09ec32'
    browser.button(type: 'submit').click

    puts '**** linkedin logged in ****'

    sea = browser.div(:class => 'nav-search-bar')
    puts sea
    if sea.exits?
    browser.div(:class => 'nav-search-bar').click
    browser.div(:class => 'type-ahead-input-container').text_field.set 'wipro'
    browser.button(:class => 'nav-search-button').click
    puts '**** searched, the results for wipro is shown '
    else
    puts 'div not present'
    end


    side = browser.div(:class => 'right-rail search-right-rail')
    puts side
    if side.present?
    puts 'div present'
    side1 = browser.divs(:class => 'right-rail search-right-rail')
    else
    puts 'div not present'
    end



    #TODO exception handling
    rescue Exception => e
    p "Error Found..... #{e.message}"
    end

the error is thrown while executing the above simply, i am able to found the div in real time but i am unable to check the div using if commands, i have also tried some codes like exists.

---------------------


Aucun commentaire:

Enregistrer un commentaire