There are several reasons why tests can pass locally but fail
remotely. Sometimes the code is run at a different resolution. The
debugging process is going to be the same. Read the error message to
see what specifically is failing, and look at the full stack trace
(use `--backtrace`) to see the exact spot of failure. Create a
screenshot at the point of failure to see if anything is obvious (on
the wrong page, element is covered by another element, element isn't
loaded, etc, etc). If it might be an issue with the driver or the
waiting logic, you can turn on the Selenium or Watir logging.

I notice that your version of Chromedriver is not compatible with your
version of Chrome
(https://chromedriver.storage.googleapis.com/2.41/notes.txt).

As for clearing up the waiting confusion, let's start with, you should
never need to use Watir::Wait directly. I'm curious where you are
seeing examples for the code you are using because it will not work.
This code is waiting for the element after it is already attempting to
use the element.

Watir::Wait.until {el}.click if el.attribute('title').include? "#{color}"

This is probably the code you want:
element.wait_until { |el| el.title.include? color }


On Mon, Aug 6, 2018 at 6:23 AM NaviHan <[email protected]> wrote:
>
> Thanks Titus
>
> The script again failed in Jenkins box but it passed in local machine. What 
> could be the reason? Im yet to get the details of the box like OS etc. Used 
> the same code snippet
>
> cta_description_element.wait_until(&:present?).text.gsub(/[^$,.A-Za-z0-9]/," 
> ")
>
>
> Also while working on a different script, I found something strange. The 
> below code snippet fails with reason as specified.
>     variation_groups_elements.map do |el|
>
>       Watir::Wait.until {el}.click if el.attribute('title').include? 
> "#{color}"
>     end
>
> Selenium::WebDriver::Error::UnknownError: unknown error: Element <a 
> class="swatchanchor" 
> href="https://ci.cottonon.com/AU/show-variation/?dwvar_2003013_color=2003013-05&amp;pid=2003013&amp;dwvar_2003013_size=XXS&amp;originalPid=2003013-05";
>  title="Select Colour: BLACK" data-attribute-type="color">...</a> is not 
> clickable at point (504, 64). Other element would receive the click: <div 
> class="loader-bg"></div>
>   (Session info: chrome=68.0.3440.84)
>   (Driver info: chromedriver=2.36.540470 
> (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 
> x86_64)
>
>
> I tried modifying the code as below expecting that the script waits for 3 
> second until it finds "el" but got the same error above
>
> Watir::Wait.until(timeout = 3) {el}.click if el.attribute('title').include? 
> "#{color}"
>
>
> However putting a 1 second sleep before the statement passed. Wondering what 
> is the difference?
>
> variation_groups_elements.map do |el|
>   sleep 1
>   Watir::Wait.until {el}.click if el.attribute('title').include? "#{color}"
> end
>
>
> Im so much confused about the Watir::Wait.until, wait_until, wait_while 
> methods. Putting a sleep instead gives more favorable outputs.
>
> Thanks in advance
> But putting a sleep before works fine. How are both different
> 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.
>
> [email protected]
> http://groups.google.com/group/watir-general
> [email protected]
> ---
> 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 [email protected].
> 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.

[email protected]
http://groups.google.com/group/watir-general
[email protected]
--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to