You are right. It works with pure Watir.
Unfortunately my company insists Pageobejct :-)

With a fresh mind wait_while and wait_until is so confusing
For instance wait_until with present flag will wait until the element is 
present and then clicks it and I clearly do not understand why its should 
click some other element in this case "loader.bg"

May be I should wait for Justin Ko to help me with this as I use page 
object.

I slightly modified the code as 

variation_groups_elements.find { |el| el.wait_until(&:present?).title.include? 
color }.click

This works when it clicks on the first color say "eucalyptus". After that the 
script does a couple of things and then go to select a different color say 
black.
Thats when this is failing.

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.41.578737 
(49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
x86_64)

The cucumber script is

And the user navigates to PDP of the product "123"
And the user selects the color "eucalyptus"
And the user selects the online size "XXS"
And the user navigates to In-Store tab
And the user searches for stock in stores by postcode 3030
And the user selects the color "black"

There is a javascript spinner which appears while loading the list of stores 
for line "And the user searches for stock in stores by postcode 3030"


But as we are using wait_until(&:present) I would expect the script to wait 
till the next color is present and then do the click.

Any more thoughts?
Selenium::WebDriver::Error::StaleElementReferenceError: stale element 
reference: element is not attached to the page document
  (Session info: chrome=68.0.3440.84)
  (Driver info: chromedriver=2.36.540470 
(e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 
x86_64)


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.

Reply via email to