[wtr-general] Re: What is the default element and page wait in Watir. Do we have to explicitly set PageObject.default_element_wait?

2019-04-15 Thread NaviHan
Hi Justin

I  have two questions here..

1. 
Im use *wait_until(&:present) *a lot.

I see *wait_until* is a method which is present in Watir and PageObject and 
as you said *wait_until of PageObject *depends on *default_element_wait*

Do you know which method is invoked when I call a *wait_until(&:present) *the 
Watir one or PageObject one?

I have commented out *default_element_wait *in hooks. The nightly suite 
hasnt run yet. So not sure about the impact.

# PageObject.default_element_wait=(10)


So if the PageObject one is invoked then lots of tests will fail
2.

If I check for an elements existence like
*element.exists? *
As watir doesnt wait here do you suggest leaving default_element_wait to 
say 30 seconds?

Cheers
Navi


On Monday, 15 April 2019 09:29:57 UTC+10, NaviHan wrote:
>
> The automation code in our project uses PageObject and yesterday's nightly 
> build shows a failure.
>
>  [31m  timed out after 10 seconds, waiting for true condition on 
> #"slide-dialog-container-cart-page", 
> :tag_name=>"div"}> (Watir::Wait::TimeoutError) [0m
>
>
> On checking hooks I found a statement
>
> PageObject.default_element_wait=(10)
>
>
> As per my undersatnding Watir has its own inbuilt page and element level 
> waits which is a default of 30 seconds?
> And the above statement over rides that to 10 seconds?
>
> Please correct me if Im wrong.
>
> Cheers
>

-- 
-- 
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.


[wtr-general] Re: Using .nil? to check the presence of an element

2019-04-15 Thread NaviHan
I have attached the html of the two line items on cart

The issue:-

*How do we check the presence of a button which can only be identified by a 
custom attribute when the button itself is not there.*

On Monday, 15 April 2019 16:03:51 UTC+10, NaviHan wrote:
>
> The shopping cart has two products, normal product and personalised product
>
> Against each normal product there is a "move to wishlist" button and there 
> is no "move to wishlist" button for personalised product.
>
> The test needs to validate the absence of the "move to wishlilist" button 
> for the personalised product. 
>
> The move to wishlist buttons are idetified by the collection
>
> buttons(:add_to_wishlist , :class => 'wishlist-container')
>
>
>
> and each button is identified by the attribute "data-variationgroup" which 
> containes the product ID passed to the test as a table
>
> The page source of 1st product which is a personalised one and hence no 
> move to wishlist button.
>
>
> 
> 
>  "dwfrm_cart_shipments_i0_items_i0_deleteProduct" value="9351785508221" 
> data-item-position="0">
> 
> Remove
> 
> 
>
> 
>
>
>
> 2nd product which is a normal product
>
>
> 
>
>
> 
>  data-productname="Woven 
> Allycia Cold Shoulder Frill Wrap Dress" class="pointer wishlist-container"
> >
> 
> Move to wishlist
> 
> 
>
> 
>  "dwfrm_cart_shipments_i0_items_i1_deleteProduct" value="9351533603802" 
> data-item-position="1">
> 
> Remove
> 
> 
>
> 
>
>
> What would be the best way to check the absence of the "move to wishlist" 
> button for the 1st product?
>
> One of my team members is using a logic
>
>   def check_move_to_wishlist_link_presence product
> add_to_wishlist_elements.find{|el| el.data_variationgroup == product}.
> nil?
>   end
>
>
>
> this is calling nil on nil which return true.
>
> Is this a good way? I see an issue where this passes even when the product 
> itself is not there
>
>

-- 
-- 
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.




















Personalised Traveller Backpack











Colour:
BLACK-GOLD







In Stock








$37.95

















Size:
OSFA











QTY



1















Remove

















Personalisation






Text: XX




Delivery Message














No change of mind returns on personalised products.  Please allow 2-3 additional days for delivery.
 































Woven Allycia Cold Shoulder Frill Wrap Dress











Colour:
BLACK







In Stock








$34.95

















Size:
M











QTY








1


















Move to wishlist






Remove
















[wtr-general] Re: What is the default element and page wait in Watir. Do we have to explicitly set PageObject.default_element_wait?

2019-04-15 Thread Justin Ko
Page-Object introduces its own couple of waits 
(https://github.com/cheezy/page-object/blob/master/lib/page-object.rb#L87-L113):

   - default_page_wait which has a default of 30 and
   - default_element_wait which has a default of 5

The default_element_wait will impact the Element methods #check_exists, 
#check_visible, #when_present, #when_not_present and #wait_until. Also 
impacts some of accessors for waiting for a page to load.

Setting Page-Object's default_element_wait only sometimes overrides Watir's 
in-built waiting. For example:

   - Watir does not do any waiting before checking if an element exists, 
   where as Page-Object's #check_exists wraps the call in a wait (using 
   default_element_wait).
   - In most cases, using #when_present will be overriding - eg 
   element.when_present.click. Page-Object's #when_present wait effectively 
   takes precedence over Watir's in-built one. That said, I would argue you 
   should be removing the #when_present calls (they are a relic from before 
   Watir had the in-built waiting).

Unfortunately not a black-and-white answer. Though again more evidence that 
we need to re-visit what Page-Object is doing given how much Watir has 
evolved.

Justin


On Sunday, April 14, 2019 at 7:29:57 PM UTC-4, NaviHan wrote:
>
> The automation code in our project uses PageObject and yesterday's nightly 
> build shows a failure.
>
>  [31m  timed out after 10 seconds, waiting for true condition on 
> #"slide-dialog-container-cart-page", 
> :tag_name=>"div"}> (Watir::Wait::TimeoutError) [0m
>
>
> On checking hooks I found a statement
>
> PageObject.default_element_wait=(10)
>
>
> As per my undersatnding Watir has its own inbuilt page and element level 
> waits which is a default of 30 seconds?
> And the above statement over rides that to 10 seconds?
>
> Please correct me if Im wrong.
>
> Cheers
>

-- 
-- 
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.


[wtr-general] Re: Using .nil? to check the presence of an element

2019-04-15 Thread NaviHan






Move to wishlist






Remove





In the above html, if I represent the button 
*name="dwfrm_cart_shipments_i0_items_i1_deleteProduct"* as  
*buttons(:remove_line_items, 
:name => /deleteProduct/)* then can I reach the other button with 
*data-variationgroup="2002690-02" *using the preceding_sibling?

remove_line_items_elements.find{|el| el.value == 
"9351785508221"}.preceding_sibling.present?

Doesnt work though. If that the case I could have solved the original issue 
with this code..


On Monday, 15 April 2019 16:03:51 UTC+10, NaviHan wrote:
>
> The shopping cart has two products, normal product and personalised product
>
> Against each normal product there is a "move to wishlist" button and there 
> is no "move to wishlist" button for personalised product.
>
> The test needs to validate the absence of the "move to wishlilist" button 
> for the personalised product. 
>
> The move to wishlist buttons are idetified by the collection
>
> buttons(:add_to_wishlist , :class => 'wishlist-container')
>
>
>
> and each button is identified by the attribute "data-variationgroup" which 
> containes the product ID passed to the test as a table
>
> The page source of 1st product which is a personalised one and hence no 
> move to wishlist button.
>
>
> 
> 
>  "dwfrm_cart_shipments_i0_items_i0_deleteProduct" value="9351785508221" 
> data-item-position="0">
> 
> Remove
> 
> 
>
> 
>
>
>
> 2nd product which is a normal product
>
>
> 
>
>
> 
>  data-productname="Woven 
> Allycia Cold Shoulder Frill Wrap Dress" class="pointer wishlist-container"
> >
> 
> Move to wishlist
> 
> 
>
> 
>  "dwfrm_cart_shipments_i0_items_i1_deleteProduct" value="9351533603802" 
> data-item-position="1">
> 
> Remove
> 
> 
>
> 
>
>
> What would be the best way to check the absence of the "move to wishlist" 
> button for the 1st product?
>
> One of my team members is using a logic
>
>   def check_move_to_wishlist_link_presence product
> add_to_wishlist_elements.find{|el| el.data_variationgroup == product}.
> nil?
>   end
>
>
>
> this is calling nil on nil which return true.
>
> Is this a good way? I see an issue where this passes even when the product 
> itself is not there
>
>

-- 
-- 
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.


[wtr-general] Using .nil? to check the presence of an element

2019-04-15 Thread NaviHan
The shopping cart has two products, normal product and personalised product

Against each normal product there is a "move to wishlist" button and there 
is no "move to wishlist" button for personalised product.

The test needs to validate the absence of the "move to wishlilist" button 
for the personalised product. 

The move to wishlist buttons are idetified by the collection

buttons(:add_to_wishlist , :class => 'wishlist-container')



and each button is identified by the attribute "data-variationgroup" which 
containes the product ID passed to the test as a table

The page source of 1st product which is a personalised one and hence no 
move to wishlist button.






Remove







2nd product which is a normal product








Move to wishlist






Remove






What would be the best way to check the absence of the "move to wishlist" 
button for the 1st product?

One of my team members is using a logic

  def check_move_to_wishlist_link_presence product
add_to_wishlist_elements.find{|el| el.data_variationgroup == product}.
nil?
  end



this is calling nil on nil which return true.

Is this a good way? I see an issue where this passes even when the product 
itself is not there

-- 
-- 
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.