Hi you don't have to use implicit wait while you use WATIR , that's needed
if you use pure selenium binding. If you use implicit wait, then you can't
know the element status immediately. Don't use implicit wait, WATIR has its
own waiting strategy.

On Wed 8 Aug, 2018, 11:16 AM NaviHan, <hishinessr...@gmail.com> wrote:

> Hi Titus and Justin
>
> "wait_for_ajax" did the job :-) I used it only at places where the spinner
> loading caused problem. Im curios where to put the code blok Titus provided
> in the hooks.rb file
> My hooks look like this.
>
> @Justin, Im curios to know why you asked if Im sure that the timing issue
> was resolved using the jQuery statement. Are these kind of issues caused by
> something else?
>
>
> require 'rubygems'
> require 'page-object'
> require 'watir'
> require 'page-object/page_factory'
> require 'log4r'
> require 'cucumber'
> require 'selenium-webdriver'
> require 'fig_newton'
>
>
>
>
> Before do|scenario|
>
>   case ENV["TEST_ENV"]
>
>     when 'dev'
>       begin
>         ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>         @browser = Watir::Browser.new :chrome
>         @browser.window.maximize
>         @browser.driver.manage.timeouts.implicit_wait = 300
>         @browser.cookies.clear
>         @browser.driver.manage.window.maximize
>         PageObject.default_element_wait=(10)
>         FigNewton.load( "#{ENV["TEST_ENV"]}" + ".yml")
>         PageObject.javascript_framework = :jquery
>       end
>     when 'dev04'
>       begin
>         ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>         @browser = Watir::Browser.new :chrome
>         @browser.window.maximize
>         @browser.driver.manage.timeouts.implicit_wait = 300
>         @browser.cookies.clear
>         @browser.driver.manage.window.maximize
>         PageObject.default_element_wait=(10)
>         FigNewton.load( "#{ENV["TEST_ENV"]}" + ".yml")
>         PageObject.javascript_framework = :jquery
>       end
>     else
>       ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
>       @browser = Watir::Browser.new :chrome
>       @browser.window.maximize
>       @browser.driver.manage.timeouts.implicit_wait = 300
>       @browser.cookies.clear
>       @browser.driver.manage.window.maximize
>       PageObject.default_element_wait=(10)
>       FigNewton.load( "dev04.yml")
>       PageObject.javascript_framework = :jquery
>   end
>
> end #before scenario
>
>
>
>
> # "after all"
> After do |scenario|
>   @browser.driver.quit
>      if (scenario.passed?)
>        puts 'Scenario Passed !'
>      else
>        puts 'Scenario Failed !'
>      end
> end
>
>
>
> AfterStep('@screen') do
>    filename = DateTime.now.strftime("%d%b%Y%H%M%S")
>    @browser.screenshot.save 
> ("C:/Users/lohit.kotian/Documents/Automation/screenshots-cucumber/#{filename}.png")
>    #@browser.screenshot.save 
> ("C:/Jenkins/workspace/screenshots-cucumber/#{filename}.png")
> end
>
>
> Around('@multipletimes') do |scenario, block|
>   $counter = 0
>   $total_times_to_run = 6
>   while $counter < $total_times_to_run  do
>      block.call
>      puts("Total times scripts were repeated = #$counter" )
>      $counter +=1
>   end
> end
>
>
> After do |scenario|
>   take_screenshot(@browser, scenario)
> end
>
> # need to check this code for the full page screenshots as a part of the 
> enhancement
>
>   def take_screenshot(browser, scenario)
>     time = Time.now.strftime("%Y-%m-%d_%H%M")
>     if scenario.failed?
>       scenario_name = scenario.name.gsub(/[^\w\-]/, ' ')
>       screenshot_path =  "#{scenario_name}" + "_failure_" + time
>       @browser.screenshot.save("./screenshots/#{screenshot_path}.png")
>     end
>
>   end
>
>
> I would require your help to clear my doubts about "wait while" and "wait
> until". I see this is something extensively used in out project but no one
> has a clear answer.A grep gave me this
> ./features/support/pages/Frontend/COG/Checkout_Page.rb:    Watir::Wait.
> while {order_summ_content_element.visible?}
> ./features/support/pages/Frontend/COG/Paypal_Page.rb:    Watir::Wait.while
> {paypal_logo_element.visible?}
> ./features/support/pages/Frontend/COG/Paypal_Page.rb:    Watir::Wait.while
> {paypal_spinner_element.visible?}
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:    if Watir::Wait.while
> {olapped_sm_window_element.visible?}
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:    # Watir::Wait.while
> {stores_elements[9].visible?}
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:    Watir::Wait.while {
> stores_elements[9].visible?}
> ./features/support/pages/Frontend/COG/Thankyou_Page.rb:    return Watir::
> Wait.while {@browser.text.include?('Did you enjoy your shopping
> experience today')}
>
>
> And Wait.until is used everywhere and the list is huge
>     ./features/support/pages/Frontend/COG/Pdp_Page.rb:    #
> Watir::Wait.until {check_stores_element}.click
>     ./features/support/pages/Frontend/COG/Pdp_Page.rb:      #return
> Watir::Wait.until {el}.parent(:index => 1).attribute('class') if
> el.text.include? "#{size}"
>     ./features/support/pages/Frontend/COG/Pdp_Page.rb:      #return
> Watir::Wait.until {el}.parent.attribute('class') if
> el.span_element.text.include? "#{size}"
>     ./features/support/pages/Frontend/COG/Pdp_Page.rb:    #return
> Watir::Wait.until {search_string_element}.attribute('value')
>     ./features/support/pages/Frontend/COG/Pdp_Page.rb:    #return
> Watir::Wait.until {search_string_element}.attribute('value')
>     ./features/support/pages/Frontend/COG/Pdp_Page.rb:    @succ_txt =
> Watir::Wait.until {pdp_success_msg_block_element}.text
>     ./features/support/pages/Frontend/COG/Pdp_Page.rb:    Watir::Wait.
> until(timeout: 30){add_to_bag_element.enabled?}
>     ./features/support/pages/Frontend/COG/Search_Page.rb:    Watir::Wait.
> until {search_field_element}.when_present.clear
>     ./features/support/pages/Frontend/COG/Search_Page.rb:    Watir::Wait.
> until {search_field_element}.when_present.click
>     ./features/support/pages/Frontend/COG/Search_Page.rb:    Watir::Wait.
> until {search_field_element}.when_present.set(arg)
>
>
> On Friday, 3 August 2018 15:12:45 UTC+10, NaviHan wrote:
>>
>> I have a functionality where I click an a link from an email a voucher
>> gets added to the shopping cart and a pop up appears with a message. Im
>> trying to assert the text in the popup
>> I have defined the element as
>>
>> div(:cta_description, :css => '.homepage-clicktoactiavte-description')
>>
>> Tried to use a mix of Watir and Pageobejct to read the text. The below
>> code works 5 out of 10 times.
>>
>> @rewards_popup_txt = Watir::Wait.until{cta_description_element}.text
>> @rewards_popup_txt = @rewards_popup_txt.gsub(/[^$,.A-Za-z0-9]/," ")
>> return @rewards_popup_txt
>>
>>
>> Tried using, which doesnt even set the @reward_popup_txt and shows error
>>
>>
>> if (Watir::Wait.while {cta_description_element.visible?})
>>   @rewards_popup_txt = cta_description_element.text
>> end
>> @rewards_popup_txt = @rewards_popup_txt.gsub(/[^$,.A-Za-z0-9]/," ")
>> return @rewards_popup_txt
>>
>> Error
>> NoMethodError: undefined method `gsub' for nil:NilClass
>> ./features/support/pages/Frontend/Cotton_On/Loyalty_Page.rb:22:in `
>> rewards_popup_description'
>>
>> Any stable way to do the job?
>>
> --
> --
> Before posting, please read
> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
>
> 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.
>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
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.

Reply via email to