[wtr-general] Re: Is there an autogenerated method in page-object that tell if the element is present?

2019-04-16 Thread NaviHan
Hi Justin

Sorry to comeback on this thread.
Today I was just trying to understand this piece of code.
I have also read your thread here 
https://stackoverflow.com/questions/36192357/is-there-a-way-to-define-a-text-field-element-type-that-does-send-key-as-default-set

Im confused about the methods named "accessor_methods"

Could you please explain a bit about the accessor_methods to define 
additional methods that will be created for the page object?

Is that a feature of Ruby?

On Friday, 1 February 2019 00:11:33 UTC+11, NaviHan wrote:
>
> I have an element defined as
>
> div(:reward_history, :class => 'reward-history-header')
>
>
> The page-object gem generated four methods for this element which are
>
>
> 'reward_history', 'reward_history_element', and 'reward_history?'
>
>
>
> The fourth method 'reward_history?' check if the element exists in the 
> DOM?
>
>
> But what if the element exists in the DOM but is hidden, which is 
> basically checking if the element is present?
>
>
> Is there an autogenerated method for this?
>
> I tried 'reward_history(:?)' but didn't work
>
> As of now I have to write a method separately which does this
>
>   def is_reward_history_present?
> return reward_history_element.present?
>   end
>
>
>
>

-- 
-- 
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: What is the default element and page wait in Watir. Do we have to explicitly set PageObject.default_element_wait?

2019-04-16 Thread NaviHan
In fact I have printed three classes

puts applied_voucher_list_element.class
puts applied_voucher_list_element.element.class
puts applied_voucher_list_element.wait_until(&:present?).class

and got


PageObject::Elements::Div
Watir::Div
Watir::Div


How  is applied_voucher_list_element.wait_until(&:present?).class returning 
Watir::Div? This should have been calling the wait_until methods of 
PageObject calss and returned PageObject::Div?

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: What is the default element and page wait in Watir. Do we have to explicitly set PageObject.default_element_wait?

2019-04-16 Thread NaviHan
Hi Justin

Also please note the error I was getting as I mention in the original post

 [31m  timed out after 10 seconds, waiting for true condition on 
#"slide-dialog-container-cart-page", 
:tag_name=>"div"}> (Watir::Wait::TimeoutError) [0m


Watir::Div  timed out after 10 seconds.
The 10 seconds because I was using defualt_element_wait.Which doesn't match

PageObject.default_element_wait=(10)




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: What is the default element and page wait in Watir. Do we have to explicitly set PageObject.default_element_wait?

2019-04-16 Thread NaviHan
Hi Justin

It a bit confusing...

For example I have defined a PageObject element as 

div(:applied_voucher_list, :class => 'applied-evouchers')


When I print the class of it 

puts applied_voucher_list_element.wait_until(&:present?).class


Im getting Watir::Div

I would expect this to return PageObject::Div?

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


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

2019-04-14 Thread NaviHan
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: Cant capture alert using "alert" method of Page Object

2019-04-12 Thread NaviHan
Thanks a lot Justin in taking time to write a detailed explanation about 
the issue. Novice automation engineers like me are very blessed to have 
people like you and Titus showing patience to explain basic things to us.

You are right about the issue. Though Im not able to confirm with the devs 
regarding the JS that runs between the click and the alert as you suggested 
the #alert function was able to capture the alert with a sleep after the 
click.

I will user the Watir alert method as its has automatic waiting.

As far as I know there is only a limited no of times alert is even shown 
our our application.

Cheers
Navi

On Thursday, 11 April 2019 12:23:16 UTC+10, NaviHan wrote:
>
> Im trying to capture the alert text and dismiss the alert using the 
> "alert" method
>
>   def test
> @browser.div(:class => 'address-details', :index =>0).click
> alert_text = alert do
>   @browser.div(:class => 'select-checkbox', :index =>1).click
> end
> sleep 10
> puts alert_text
>
>
>   end
>
>
> I have passed @browser.div(:class => 'select-checkbox', :index =>1).click  
> into the alert method which actually triggers the alert
>
> As per the implementation this should capture the alert text and click OK
>
> However I'm getting this error
>
> elenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: 
> {Alert text : This address cannot be used.}
>   (Session info: chrome=73.0.3683.86)
>   (Driver info: chromedriver=2.38.552522 
> (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 
> x86_64)
>
>
> A video of the issue here @ 
> https://drive.google.com/file/d/1Di9idgfqjE7TLSn5QG7pgUFxpln3kben/view?usp=sharing
>

-- 
-- 
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: Cant capture alert using "alert" method of Page Object

2019-04-10 Thread NaviHan
Hi Titus

@browser.div(:class => 'address-details', :index =>0).click
# alert_text = alert do
#   @browser.div(:class => 'select-checkbox', :index =>1).click
# end
# sleep 10
# puts alert_text
@browser.div(:class => 'select-checkbox', :index =>1).click
puts @browser.alert.text
@browser.alert.ok


This worked.

But I would like to know why the PageObject method alert is not working as 
expected.

May be wait for Justin :-)

On Thursday, 11 April 2019 12:23:16 UTC+10, NaviHan wrote:
>
> Im trying to capture the alert text and dismiss the alert using the 
> "alert" method
>
>   def test
> @browser.div(:class => 'address-details', :index =>0).click
> alert_text = alert do
>   @browser.div(:class => 'select-checkbox', :index =>1).click
> end
> sleep 10
> puts alert_text
>
>
>   end
>
>
> I have passed @browser.div(:class => 'select-checkbox', :index =>1).click  
> into the alert method which actually triggers the alert
>
> As per the implementation this should capture the alert text and click OK
>
> However I'm getting this error
>
> elenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: 
> {Alert text : This address cannot be used.}
>   (Session info: chrome=73.0.3683.86)
>   (Driver info: chromedriver=2.38.552522 
> (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 
> x86_64)
>
>
> A video of the issue here @ 
> https://drive.google.com/file/d/1Di9idgfqjE7TLSn5QG7pgUFxpln3kben/view?usp=sharing
>

-- 
-- 
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: Cant capture alert using "alert" method of Page Object

2019-04-10 Thread NaviHan


On Thursday, 11 April 2019 12:23:16 UTC+10, NaviHan wrote:
>
> Im trying to capture the alert text and dismiss the alert using the 
> "alert" method
>
>   def test
> @browser.div(:class => 'address-details', :index =>0).click
> alert_text = alert do
>   @browser.div(:class => 'select-checkbox', :index =>1).click
> end
> sleep 10
> puts alert_text
>
>
>   end
>
>
> I have passed @browser.div(:class => 'select-checkbox', :index =>1).click  
> into the alert method which actually triggers the alert
>
> As per the implementation this should capture the alert text and click OK
>
> However I'm getting this error
>
> elenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: 
> {Alert text : This address cannot be used.}
>   (Session info: chrome=73.0.3683.86)
>   (Driver info: chromedriver=2.38.552522 
> (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 
> x86_64)
>
>
> A video of the issue here @ 
> https://drive.google.com/file/d/1Di9idgfqjE7TLSn5QG7pgUFxpln3kben/view?usp=sharing
>

-- 
-- 
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] Cant capture alert using "alert" method of Page Object

2019-04-10 Thread NaviHan
Im trying to capture the alert text and dismiss the alert using the "alert" 
method

  def test
@browser.div(:class => 'address-details', :index =>0).click
alert_text = alert do
  @browser.div(:class => 'select-checkbox', :index =>1).click
end
sleep 10
puts alert_text


  end


I have passed @browser.div(:class => 'select-checkbox', :index =>1).click  
into the alert method which actually triggers the alert

As per the implementation this should capture the alert text and click OK

However I'm getting this error

elenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: 
{Alert text : This address cannot be used.}
  (Session info: chrome=73.0.3683.86)
  (Driver info: chromedriver=2.38.552522 
(437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 
x86_64)


A video of the issue here 
@ 
https://drive.google.com/file/d/1Di9idgfqjE7TLSn5QG7pgUFxpln3kben/view?usp=sharing

-- 
-- 
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: How to keep the Watir browser run on the backend?

2019-04-10 Thread NaviHan
  args = ['--window-position=-3000,0']
  browser = Watir::Browser.new :chrome, options: {args: args}

Doesnt work either.

Can the OP confirm if it works for him?

On Wednesday, 10 April 2019 22:42:13 UTC+10, watirQ wrote:
>
> Experts 
>
> Each time when use .goto or open a new tab, the browser window will lump 
> to the frontend of the screen. How to keep the Watir browser run on the 
> backend, so that will  not interrupt other works
>
> Thanks
>

-- 
-- 
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: Is there a way to duplicate a tab using Watir

2019-04-10 Thread NaviHan
I want to duplicate the browser in a new tab. Not open a blank new tab.

And are we sure that javascript is the only way to open a new tab?

On Wednesday, 10 April 2019 13:39:32 UTC+10, NaviHan wrote:
>
> Is there a way to duplicate a tab using Watir?
>
> (in chrome, right click on tab>Duplicate tab)
>
> I know we can use the javascript to open a new tab?
> Even if its new tab is there a Watir way to do that?
>
> @browser.execute_script("window.open('http://www.google.com', '_blank')")
>
>
>
>

-- 
-- 
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: How to keep the Watir browser run on the backend?

2019-04-10 Thread NaviHan
Tried this, browser didnt minimize

  args = ['--allow-running-insecure-content --window-position=-3000, 0']
  browser = Watir::Browser.new :chrome, options: {args: args}

Titus is this correct?
On Wednesday, 10 April 2019 22:42:13 UTC+10, watirQ wrote:
>
> Experts 
>
> Each time when use .goto or open a new tab, the browser window will lump 
> to the frontend of the screen. How to keep the Watir browser run on the 
> backend, so that will  not interrupt other works
>
> Thanks
>

-- 
-- 
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: How to keep the Watir browser run on the backend?

2019-04-10 Thread NaviHan
Try this after you open the browser
browser.window.move_to(-3000, 0)

This will minimize the window

On Wednesday, 10 April 2019 22:42:13 UTC+10, watirQ wrote:
>
> Experts 
>
> Each time when use .goto or open a new tab, the browser window will lump 
> to the frontend of the screen. How to keep the Watir browser run on the 
> backend, so that will  not interrupt other works
>
> Thanks
>

-- 
-- 
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] Is there a way to duplicate a tab using Watir

2019-04-09 Thread NaviHan
Is there a way to duplicate a tab using Watir?

(in chrome, right click on tab>Duplicate tab)

I know we can use the javascript to open a new tab?
Even if its new tab is there a Watir way to do that?

@browser.execute_script("window.open('http://www.google.com', '_blank')")



-- 
-- 
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: Trouble undersatnding "Around" hook

2019-04-04 Thread NaviHan
Thanks Justin
I have posted the query in Cukes mailing list.

Cheers
Navi

On Friday, 29 March 2019 16:33:14 UTC+11, NaviHan wrote:
>
> Im trying to understand how the around hooks work
>
> Im sorry if the question is very basic. I cant find the implementation of 
> "Around" in Cucumber API docs as well (checked  
>
> *Cucumber::RbSupport::RbDsl*
> in
>
> *Around **do *|*scenario*, *block*|
>
>   puts *"About to run *#{*scenario*.name}
>
> *"  **block*.call
>
>   puts *"Finished running *#{*scenario*.name}
>
> *"**end*
>
>
> I was expecting scenario.call instead of block.call
>
> How does the scenario gets passed to block?
>

-- 
-- 
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: Trouble undersatnding "Around" hook

2019-04-03 Thread NaviHan
Hi Titus/Justin

If you could help me here understanding this...

Also what is the order in which the before, after and around hooks run.

I tried printing the order and as per my experimenatation the order is

1. Around
2. Before &
3. After

Some of the articles I read says this order is fluctuating.. Is this true?

On Friday, 29 March 2019 16:33:14 UTC+11, NaviHan wrote:
>
> Im trying to understand how the around hooks work
>
> Im sorry if the question is very basic. I cant find the implementation of 
> "Around" in Cucumber API docs as well (checked  
>
> *Cucumber::RbSupport::RbDsl*
> in
>
> *Around **do *|*scenario*, *block*|
>
>   puts *"About to run *#{*scenario*.name}
>
> *"  **block*.call
>
>   puts *"Finished running *#{*scenario*.name}
>
> *"**end*
>
>
> I was expecting scenario.call instead of block.call
>
> How does the scenario gets passed to block?
>

-- 
-- 
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] Trouble undersatnding "Around" hook

2019-03-28 Thread NaviHan
Im trying to understand how the around hooks work

Im sorry if the question is very basic. I cant find the implementation of 
"Around" in Cucumber API docs as well (checked  

*Cucumber::RbSupport::RbDsl*
in

*Around **do *|*scenario*, *block*|

  puts *"About to run *#{*scenario*.name}

*"  **block*.call

  puts *"Finished running *#{*scenario*.name}

*"**end*


I was expecting scenario.call instead of block.call

How does the scenario gets passed to block?

-- 
-- 
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: How to check if a collection is present in PageObject?

2019-03-27 Thread NaviHan
Hi Titus

I read a wondeful article about the enumerable methods, Any, All, None & 
One.

https://www.rubyguides.com/2018/10/any-all-none-one/

For the particular example in the first post, I used the below code to just 
return if wishlist is empty(No buttons are present on the wishlist page) 
and this works.

return if !products_on_wishlist_elements.any?

My doubt is 

When you define the elements as buttons(:products_on_wishlist, :class => 
'product-quick-add') and there are no buttons on wishlist page, is the 
collection array set to empty or nil ?

Because 
[nil].any?  

also returns false

Cheers
NaviHan

On Wednesday, 27 March 2019 11:08:54 UTC+11, NaviHan wrote:
>
> Hi 
>
> I have a collections of buttons defined as  is the element 
>
 

>
> buttons(:products_on_wishlist, :class => 'product-quick-add')
>
>
>
> Basically they represent the products on wishlist 
>
> The page can have
> 1. No products (no buttons)
> 2. One product (1 button)
> 3. More than one products (more than 1 button)
>
> I need to check if the wishlist page is empty. Basically I want to check 
> if the button is present on not.
> Because the button is defined as a collection
>
>
> products_on_wishlist_elemets.present? 
>
>
> is not working.
>
> Is there a way to check if the collection is present or not?
>
>
>

-- 
-- 
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: How to check if a collection is present in PageObject?

2019-03-26 Thread NaviHan
Oops
I thought because in a case where the wishlist is empty (i:e no buttons on 
wishlist page) the buttons are undefined.

So thats not the case?
When the page class is loaded all the elements are declared or what?

Thsi si equivalent to doing on irb

a.any?
without declaring a as a = [ ]

irb(main):001:0> a.any
Traceback (most recent call last):
2: from C:/Ruby25-x64/bin/irb.cmd:19:in `'
1: from (irb):1
NameError (undefined local variable or method `a' for main:Object)
irb(main):002:0> a = []
=> []
irb(main):003:0> a.any?
=> false
irb(main):004:0>



On Wednesday, 27 March 2019 11:08:54 UTC+11, NaviHan wrote:
>
> Hi 
>
> I have a collections of buttons defined as 
>
> buttons(:products_on_wishlist, :class => 'product-quick-add')
>
>
>
> Basically they represent the products on wishlist 
>
> The page can have
> 1. No products (no buttons)
> 2. One product (1 button)
> 3. More than one products (more than 1 button)
>
> I need to check if the wishlist page is empty. Basically I want to check 
> if the button is present on not.
> Because the button is defined as a collection
>
>
> products_on_wishlist_elemets.present? 
>
>
> is not working.
>
> Is there a way to check if the collection is present or not?
>
>
>

-- 
-- 
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: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-26 Thread NaviHan
Hi Justin

Thanks for the detailed explanation.

But cant we use collections here.

Instead of declaring links as 

links(:product_names) { div(class: "price-and-quick-add-button-wrapper").
links(class: "name-link") }

isnt
links(:product_name, :class => 'name-link')


better?
And then use

product_names_elements[0] and product_name_elemets[1] to access links?


On Sunday, 24 March 2019 17:15:53 UTC+11, NaviHan wrote:
>
> I have seen in my project using css to identify elements using PageObject.
> I always use attributes like id, class and name to identify elements.
>
> Which is the better way and why?
>

-- 
-- 
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] How to check if a collection is present in PageObject?

2019-03-26 Thread NaviHan
Hi 

I have a collections of buttons defined as 

buttons(:products_on_wishlist, :class => 'product-quick-add')



Basically they represent the products on wishlist 

The page can have
1. No products (no buttons)
2. One product (1 button)
3. More than one products (more than 1 button)

I need to check if the wishlist page is empty. Basically I want to check if 
the button is present on not.
Because the button is defined as a collection


products_on_wishlist_elemets.present? 


is not working.

Is there a way to check if the collection is present or not?


-- 
-- 
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: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-26 Thread NaviHan
Hi Titus

Today I saw a team member defining elements like this

+  a(:start_shopping_link, :css => "a.start-shopping")

<https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#add-comment>
 
<https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#Lcuke-tests/features/support/pages/Frontend/Cotton_On/Wishlist_Page.rbT12>

+  links(:product_names, :css => ".price-and-quick-add-button-wrapper 
a.name-link")

<https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#add-comment>
 
<https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#Lcuke-tests/features/support/pages/Frontend/Cotton_On/Wishlist_Page.rbT13>

+  links(:product_thumbnails, :css => "a.thumb-link")

<https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#add-comment>
 
<https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#Lcuke-tests/features/support/pages/Frontend/Cotton_On/Wishlist_Page.rbT14>

+  span(:remove_all_link, :css=> ".wishlist-remove-all span")


Heavy use of css.
I cant tell them why they should use css :-)

Could you please let me know the disadvantage here?

On Sunday, 24 March 2019 17:15:53 UTC+11, NaviHan wrote:
>
> I have seen in my project using css to identify elements using PageObject.
> I always use attributes like id, class and name to identify elements.
>
> Which is the better way and why?
>

-- 
-- 
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: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-24 Thread NaviHan
Thanks Titus. 
But what if someone ask, why cant I use the css or xpath.
If you use them what is issue and how we avoid that with attributes like 
is, class or data-set?

On Sunday, 24 March 2019 17:15:53 UTC+11, NaviHan wrote:
>
> I have seen in my project using css to identify elements using PageObject.
> I always use attributes like id, class and name to identify elements.
>
> Which is the better way and why?
>

-- 
-- 
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] Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-24 Thread NaviHan
I have seen in my project using css to identify elements using PageObject.
I always use attributes like id, class and name to identify elements.

Which is the better way and why?

-- 
-- 
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] New books on Cucumber, Pageobjects, Watir and Selenium etc

2019-02-20 Thread NaviHan
Hi All

Just wondering if any recent books have been written on Cucumber, 
Pageobjects, Watir, Selenium etc

Books I have already read

1. Cucumber and Cheese by Jeff Morgan
2. Watirways by Justin Ko
3. Collection of books on Automation written by Zhimin Zhan

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: Is there an autogenerated method in page-object that tell if the element is present?

2019-02-01 Thread NaviHan
Thanks Justin..
I have two more question though.

1. How does the the method in monkey_path.b takes precedence over the 
method in actual page-object gem?
2. There are may intances in the application where a div element receives 
the click rather than a button.

eg
  div(:expand_perks_section_icon, :css => '.icon-plus-wrapper')



This element is  a div and receives the click as shown below.
  def expand_perks_section
expand_perks_section_icon_element.when_present.click
  end



Writing a separate method each time for such things is really a pain.
Is there a better solution for such cases

On Friday, 1 February 2019 00:11:33 UTC+11, NaviHan wrote:
>
> I have an element defined as
>
> div(:reward_history, :class => 'reward-history-header')
>
>
> The page-object gem generated four methods for this element which are
>
>
> 'reward_history', 'reward_history_element', and 'reward_history?'
>
>
>
> The fourth method 'reward_history?' check if the element exists in the 
> DOM?
>
>
> But what if the element exists in the DOM but is hidden, which is 
> basically checking if the element is present?
>
>
> Is there an autogenerated method for this?
>
> I tried 'reward_history(:?)' but didn't work
>
> As of now I have to write a method separately which does this
>
>   def is_reward_history_present?
> return reward_history_element.present?
>   end
>
>
>
>

-- 
-- 
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: Usage of block in hooks.rb

2019-02-01 Thread NaviHan
Hi Lakshya

Here is the hooks.rb used in our project..

Eventhough the the browser is assigned to instance variable @browser we 
still get to see all the details you mentioned. So Im not quite getting the 
difference between the two Before hooks

require 'rubygems'
require 'page-object'
require 'watir'
require 'page-object/page_factory'
require 'log4r'
require 'cucumber'
require 'selenium-webdriver'
require 'fig_newton'
require 'watir-screenshot-stitch'
require 'mini_magick'

args = ['--allow-running-insecure-content']
browser = Watir::Browser.new :chrome, options: {args: args}
$code_retry = 30

Before do
 @browser = browser
end


Before do|scenario|
ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
DataMagic.load_for_scenario(scenario)
@browser.window.maximize
@browser.driver.manage.timeouts.implicit_wait = 0
@browser.cookies.clear
@browser.driver.manage.window.maximize
PageObject.default_element_wait=(10)
PageObject.javascript_framework = :jquery
#Selenium::WebDriver.logger.level = :info
end #before scenario




# "after all"
After do |scenario|
  @browser.execute_script("javascript:localStorage.clear();")
  @browser.cookies.clear
 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

at_exit do
 browser.close
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")
opts = {:page_height_limit => 5000}
if scenario.failed?
  scenario_name = scenario.name.gsub(/[^\w\-]/, ' ')
  screenshot_path =  "#{scenario_name}" + "_failure_" + time
  
@browser.screenshot.save_stitch("./screenshots/#{screenshot_path}.png", 
browser, opts)
end
  end





On Tuesday, 29 January 2019 16:47:10 UTC+11, NaviHan wrote:
>
> Hi all
>
> Im just looking for some good documentation which explains the usage of 
> blocks in hooks.rb
>
> For example "Before", "After" , "AfterStep" etc...
>
> Thanks in advance
>

-- 
-- 
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: Usage of block in hooks.rb

2019-01-31 Thread NaviHan
Thanks Lakshya for the detailed explanation.

So if I want to execute a scenario 3 times, here is the order of execution

iteration 1 -> Before Hook   Scenario Steps  After Hook
iteration 2 -> Before Hook   Scenario Steps  After Hook
iteration 3 -> Before Hook   Scenario Steps  After Hook

Or is it

Before Hook
iteration 1 -> Scenario Steps
iteration 2 -> Scenario Steps
iteration 3 -> Scenario Steps
After Hook

Also what is the difference between

Before do
 @browser = browser
end

and


Before do |scenario|
 @browser = browser
end



On Tuesday, 29 January 2019 16:47:10 UTC+11, NaviHan wrote:
>
> Hi all
>
> Im just looking for some good documentation which explains the usage of 
> blocks in hooks.rb
>
> For example "Before", "After" , "AfterStep" etc...
>
> Thanks in advance
>

-- 
-- 
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: Is there an autogenerated method in page-object that tell if the element is present?

2019-01-31 Thread NaviHan
Thanks Justin for creating a feature request.

What I have done is I have created a file name monkeypatch.rb and put the 
code you have given in there.
Changed the script to use and it passed.

expect(on(MyAccountPage).reward_history?).to be_falsey

Could you please confirm if this is the right way to do this.

By the way Im confused how the script know it has to give priority to 
standard_methods in the monkypatch.rb rather in the actual PageObject 
module?


On Friday, 1 February 2019 00:11:33 UTC+11, NaviHan wrote:
>
> I have an element defined as
>
> div(:reward_history, :class => 'reward-history-header')
>
>
> The page-object gem generated four methods for this element which are
>
>
> 'reward_history', 'reward_history_element', and 'reward_history?'
>
>
>
> The fourth method 'reward_history?' check if the element exists in the 
> DOM?
>
>
> But what if the element exists in the DOM but is hidden, which is 
> basically checking if the element is present?
>
>
> Is there an autogenerated method for this?
>
> I tried 'reward_history(:?)' but didn't work
>
> As of now I have to write a method separately which does this
>
>   def is_reward_history_present?
> return reward_history_element.present?
>   end
>
>
>
>

-- 
-- 
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] Is there an autogenerated method in page-object that tell if the element is present?

2019-01-31 Thread NaviHan
I have an element defined as

div(:reward_history, :class => 'reward-history-header')


The page-object gem generated four methods for this element which are


'reward_history', 'reward_history_element', and 'reward_history?'



The fourth method 'reward_history?' check if the element exists in the DOM?


But what if the element exists in the DOM but is hidden, which is basically 
checking if the element is present?


Is there an autogenerated method for this?

I tried 'reward_history(:?)' but didn't work

As of now I have to write a method separately which does this

  def is_reward_history_present?
return reward_history_element.present?
  end



-- 
-- 
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] What happened to "cheezy"

2019-01-31 Thread NaviHan
Just curious , whats Jeff Morgan doing these days? There has been no posts 
on his website cheezyworld since March 2017.
Missing his articles on Test Automation.

Is there anyone Automation Gurus we can follow for day to day reading?

-- 
-- 
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: Usage of block in hooks.rb

2019-01-29 Thread NaviHan
Thanks Laskhya. Im aware of the use of the hooks. But rathet confused by 
the syntax.. Here are the blocks in my projects hooks.rb

Sometimes "scenario" is passed, Sometimes "scenario" and "block" are 
passed. Its quite confusing how exactly its doing?

Before do
 @browser = browser
end
Before do|scenario|
 ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
 DataMagic.load('order_details.yml')
 DataMagic.load_for_scenario(scenario)
end
After do |scenario|
 @browser.execute_script("javascript:localStorage.clear();")
 @browser.cookies.clear
 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




On Tuesday, 29 January 2019 16:47:10 UTC+11, NaviHan wrote:
>
> Hi all
>
> Im just looking for some good documentation which explains the usage of 
> blocks in hooks.rb
>
> For example "Before", "After" , "AfterStep" etc...
>
> Thanks in advance
>

-- 
-- 
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] Usage of block in hooks.rb

2019-01-28 Thread NaviHan
Hi all

Im just looking for some good documentation which explains the usage of 
blocks in hooks.rb

For example "Before", "After" , "AfterStep" etc...

Thanks in advance

-- 
-- 
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: populate_page_with data_for using data_magic is not working for a select_list?

2019-01-13 Thread NaviHan
Strange I got it working when its in both places


select_list(:auth_to_leave_list, :id => 
'dwfrm_shippingaddress_authorityToLeave')


auth_to_leave_list: ~randomize ['Leave out of the weather']




&

page.populate_check_out_page_with_data
 if (page.auth_to_leave_present? && @site_country.to_s == 'au')
 page.auth_to_leave_list="Leave out of the weather"
 end




On Monday, 14 January 2019 14:58:25 UTC+11, NaviHan wrote:
>
> My order_details.yml files looks like this
>
> order_details:
>  site: au
>  products:
>  - 9351785586540
>  - 9350486827327
>  qty:
>  - 2
>  - 5
>  coupons_bag: []
>  vouchers_bag: []
>  email_add: ~randomize 
> ['cottononqa+orderthruau...@gmail.com','cottononqa+orderthruau...@gmail.com']
>  first_name: ~first_name
>  last_name: ~last_name
>  phone: 0403222638
>  hd_first_name: ~first_name
>  hd_last_name: ~last_name
>  hd_country: ~randomize ['Australia']
>  homdel_address1: ~street_address
>  homedel_city: ~city
>  homedel_state_abb: ~randomize ['Queensland']
>  homedel_postcode: ~randomize ['3030', '3075', '3125']
>  auth_to_leave_list: ~randomize ['Leave out of the weather']
>  vouchers_checkout:
>  - 9840150120702065
>  - 9840150120702066
>  gift_card_no:
>  - 2790030169169063156
>  gift_card_pin:
>  - 2043
>  payment_type: creditcard
>
>
> Out of which "homedel_state_abb" and "auth_to_leave_list" are two select 
> lists
>
> Im having problem with the select list, "auth_to_leave_list", for some 
> reason the value is not getting set using 
>
> page.populate_check_out_page_with_data
> def populate_check_out_page_with_data
>  populate_page_with data_for(:order_details)
> end
>
>
>
>
> I pulled it out of the yml and tried using a method.
>
> page.populate_check_out_page_with_data
>  if (page.auth_to_leave_present? && @site_country.to_s == 'au')
>  page.auth_to_leave_list="Leave out of the weather"
>  end
>
>
>
> Still that doesnt work.
>
> If I remove the populate_page_with data_for call then the select list is 
> getting set.
>
> if (page.auth_to_leave_present? && @site_country.to_s == 'au')
>  page.auth_to_leave_list="Leave out of the weather"
> end
>
> Any clues?
>

-- 
-- 
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] populate_page_with data_for using data_magic is not working for a select_list?

2019-01-13 Thread NaviHan
My order_details.yml files looks like this

order_details:
 site: au
 products:
 - 9351785586540
 - 9350486827327
 qty:
 - 2
 - 5
 coupons_bag: []
 vouchers_bag: []
 email_add: ~randomize 
['cottononqa+orderthruau...@gmail.com','cottononqa+orderthruau...@gmail.com']
 first_name: ~first_name
 last_name: ~last_name
 phone: 0403222638
 hd_first_name: ~first_name
 hd_last_name: ~last_name
 hd_country: ~randomize ['Australia']
 homdel_address1: ~street_address
 homedel_city: ~city
 homedel_state_abb: ~randomize ['Queensland']
 homedel_postcode: ~randomize ['3030', '3075', '3125']
 auth_to_leave_list: ~randomize ['Leave out of the weather']
 vouchers_checkout:
 - 9840150120702065
 - 9840150120702066
 gift_card_no:
 - 2790030169169063156
 gift_card_pin:
 - 2043
 payment_type: creditcard


Out of which "homedel_state_abb" and "auth_to_leave_list" are two select 
lists

Im having problem with the select list, "auth_to_leave_list", for some 
reason the value is not getting set using 

page.populate_check_out_page_with_data
def populate_check_out_page_with_data
 populate_page_with data_for(:order_details)
end




I pulled it out of the yml and tried using a method.

page.populate_check_out_page_with_data
 if (page.auth_to_leave_present? && @site_country.to_s == 'au')
 page.auth_to_leave_list="Leave out of the weather"
 end



Still that doesnt work.

If I remove the populate_page_with data_for call then the select list is 
getting set.

if (page.auth_to_leave_present? && @site_country.to_s == 'au')
 page.auth_to_leave_list="Leave out of the weather"
end

Any clues?

-- 
-- 
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: Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {Alert text : Bad response - parser error!}

2018-12-06 Thread NaviHan



Basically the script gets a focus on "Place Order" button and clicks it. At 
this point the alert occurs

2018-12-07 10:33:21 INFO Selenium>>> 
http://127.0.0.1:9515/session/5ee6d653d161aabc0a8fe64ac2c8391f/execute | 
{"script":"return (function(){\nreturn 
arguments[0].focus();\n}\n).apply(null, 
arguments)","args":[{"ELEMENT":"0.1093678988911102-26"}]}
2018-12-07 10:33:21 INFO Selenium <- 
{"sessionId":"5ee6d653d161aabc0a8fe64ac2c8391f","status":0,"value":null}
2018-12-07 10:33:21 INFO Selenium -> GET 
session/5ee6d653d161aabc0a8fe64ac2c8391f/element/0.1093678988911102-26/enabled
2018-12-07 10:33:21 INFO Selenium <- 
{"sessionId":"5ee6d653d161aabc0a8fe64ac2c8391f","status":0,"value":true}
2018-12-07 10:33:21 INFO Selenium -> GET 
session/5ee6d653d161aabc0a8fe64ac2c8391f/element/0.1093678988911102-26/enabled
2018-12-07 10:33:21 INFO Selenium <- 
{"sessionId":"5ee6d653d161aabc0a8fe64ac2c8391f","status":0,"value":true}
2018-12-07 10:33:21 INFO Selenium -> POST 
session/5ee6d653d161aabc0a8fe64ac2c8391f/element/0.1093678988911102-26/click
2018-12-07 10:33:24 INFO Selenium <- 
{"sessionId":"5ee6d653d161aabc0a8fe64ac2c8391f","status":0,"value":null}
Time after is 2018-12-07 10:33:24 +1100
2018-12-07 10:33:24 INFO Selenium -> POST 
session/5ee6d653d161aabc0a8fe64ac2c8391f/element
2018-12-07 10:33:24 INFO Selenium>>> 
http://127.0.0.1:9515/session/5ee6d653d161aabc0a8fe64ac2c8391f/element | 
{"using":"xpath","value":".//*[local-name()='div'][contains(concat(' ', @class, 
' '), ' order-num ')]"}
2018-12-07 10:33:24 INFO Selenium <- 
{"sessionId":"5ee6d653d161aabc0a8fe64ac2c8391f","status":26,"value":{"message":"unexpected
 alert open: {Alert text : Couldn't load credit card!}\n  (Session info: 
chrome=70.0.3538.110)\n  (Driver info: chromedriver=2.41.578737 
(49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
x86_64)"}}

Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {Alert 
text : Couldn't load credit card!}
  (Session info: chrome=70.0.3538.110)
  (Driver info: chromedriver=2.41.578737 
(49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
x86_64)
./features/support/pages/Frontend/Cotton_On/Thankyou_Page.rb:93:in 
`find_dw_order_number'
./features/step_definitions/Checkout_Page_steps.rb:1449:in `block (2 levels) in 
'
./features/step_definitions/Checkout_Page_steps.rb:1448:in `/^Thankyou page is 
shown with details for the user$/'
./features/Giftcards-AU.feature:269:in `Then Thankyou page is shown with 
details for the user'

Skipped step

Skipped step

Skipped step

Skipped step
2018-12-07 10:33:24 WARN Watir Screenshot Stitch [DEPRECATION] Passing the 
browser is deprecated and will no longer work in version 0.7.0 
/lib/watir-screenshot-stitch.rb:31
2018-12-07 10:33:24 INFO Selenium -> POST 
session/5ee6d653d161aabc0a8fe64ac2c8391f/execute
2018-12-07 10:33:24 INFO Selenium>>> 
http://127.0.0.1:9515/session/5ee6d653d161aabc0a8fe64ac2c8391f/execute | 
{"script":"return window.innerHeight","args":[]}
2018-12-07 10:33:24 INFO Selenium <- 
{"sessionId":"5ee6d653d161aabc0a8fe64ac2c8391f","status":26,"value":{"message":"unexpected
 alert open: {Alert text : Couldn't load credit card!}\n  (Session info: 
chrome=70.0.3538.110)\n  (Driver info: chromedriver=2.41.578737 
(49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
x86_64)"}}

Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {Alert 
text : Couldn't load credit card!}
  (Session info: chrome=70.0.3538.110)
  (Driver info: chromedriver=2.41.578737 
(49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
x86_64)
./features/support/hooks.rb:88:in `take_screenshot'
./features/support/hooks.rb:73:in `After'

Scenario Failed !




On Wednesday, 5 December 2018 13:31:56 UTC+11, NaviHan wrote:
>
>  Im having a tough time with this intermittent error I get on checkout 
> page once all the details are filled and customer hits payment button.
>
> Sometimes
> Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {
> Alert text : Bad response - parser error!}
>
>  
>
>   (Session info: chrome=70.0.3538.102) 
>
>   (Driver info: chromedriver=2.41.578737 (
> 49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 
> SP1 x86_64) 
>
> ./features/support/pages/Frontend/Cotton_On/Thankyou_Page.rb:91:in 
> `find_dw_order_number' 
>
>
> ./features/s

[wtr-general] Re: Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {Alert text : Bad response - parser error!}

2018-12-06 Thread NaviHan
Hi Titus

Just before the error what I get is

2018-12-07 10:33:24 INFO Selenium <- {"sessionId":
"5ee6d653d161aabc0a8fe64ac2c8391f","status":0,"value":null}
Time after is 2018-12-07 10:33:24 +1100
2018-12-07 10:33:24 INFO Selenium -> POST session/
5ee6d653d161aabc0a8fe64ac2c8391f/element
2018-12-07 10:33:24 INFO Selenium>>> 
http://127.0.0.1:9515/session/5ee6d653d161aabc0a8fe64ac2c8391f/element 
| {"using":"xpath","value":".//*[local-name()='div'][contains(concat(' ', 
@class, ' '), ' order-num ')]"}
2018-12-07 10:33:24 INFO Selenium <- {"sessionId":
"5ee6d653d161aabc0a8fe64ac2c8391f","status":26,"value":{"message":"unexpected 
alert open: {Alert text : Couldn't load credit card!}\n  (Session info: 
chrome=70.0.3538.110)\n  (Driver info: chromedriver=2.41.578737 
(49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
x86_64)"}}

Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {
Alert text : Couldn't load credit card!}
  (Session info: chrome=70.0.3538.110)
  (Driver info: chromedriver=2.41.578737 
(49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
x86_64)
./features/support/pages/Frontend/Cotton_On/Thankyou_Page.rb:93:in 
`find_dw_order_number'
./features/step_definitions/Checkout_Page_steps.rb:1449:in `block (2 
levels) in '
./features/step_definitions/Checkout_Page_steps.rb:1448:in `/^Thankyou page 
is shown with details for the user$/'
./features/Giftcards-AU.feature:269:in `Then Thankyou page is shown with 
details for the user'



The hard thing is I dont see any alert when I do this test manually.

Is there any way i cant print the browser console errors at this point of 
failure?




On Wednesday, 5 December 2018 13:31:56 UTC+11, NaviHan wrote:
>
>  Im having a tough time with this intermittent error I get on checkout 
> page once all the details are filled and customer hits payment button.
>
> Sometimes
> Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {
> Alert text : Bad response - parser error!}
>
>  
>
>   (Session info: chrome=70.0.3538.102) 
>
>   (Driver info: chromedriver=2.41.578737 (
> 49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 
> SP1 x86_64) 
>
> ./features/support/pages/Frontend/Cotton_On/Thankyou_Page.rb:91:in 
> `find_dw_order_number' 
>
>
> ./features/step_definitions/Checkout_Page_steps.rb:1395:in `block (2 
> levels) in ' 
>
> ./features/step_definitions/Checkout_Page_steps.rb:1394:in `/^Thankyou 
> page is shown with details for the user$/' 
>
> ./features/Giftcards-AU.feature:233:in `Then Thankyou page is shown with 
> details for the user'
>
>  
>
> Sometimes
>
> Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {
> Alert text : Couldn't load credit card!}
>
>  
>
>   (Session info: chrome=70.0.3538.102) 
>
>   (Driver info: chromedriver=2.41.578737 
> (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
> x86_64)
>
>
>  
>
> In order for the dev to have a look I need to give them the browser 
> console logs at the point of failure. What happens is that some times I get 
> the error on "wait_for_ajax" and some time on "wait_and_click" method. The 
> test exits abruptly with the errors above and no screenshots ate taken
>
> Is there a way I can get the browser console logs at this point?
>
>
>
> def place_order
>  wait_for_ajax
>  wait_and_click place_order_btn_element
> end
>
>
> def wait_and_click element
>  begin
>  retries ||= 0
>  Watir::Wait.until {element}.focus
>  Watir::Wait.until {element}.click
>  rescue Selenium::WebDriver::Error::UnknownError
>  retry if (retries += 1) < $code_retry
>  rescue Watir::Exception::UnknownObjectException
>  retry if (retries += 1) < $code_retry
>  end
> end
>
>
>
>
>

-- 
-- 
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: Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {Alert text : Bad response - parser error!}

2018-12-04 Thread NaviHan
Thanks Titus, Yes I know the issue with, "Watir::Wait.until {element}" this 
is all over our automation code , the previous automation tester did this 
practise. In on my list to clean this up 

But sorry I didnt quite understand the statement "Also log the wire calls 
getting sent to the driver to see exactly what is causing the alert 
(`Selenium::WebDriver.logger.level = :info`)". Could you please a bit more 
clear..

On Wednesday, 5 December 2018 13:31:56 UTC+11, NaviHan wrote:
>
>  Im having a tough time with this intermittent error I get on checkout 
> page once all the details are filled and customer hits payment button.
>
> Sometimes
> Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {
> Alert text : Bad response - parser error!}
>
>  
>
>   (Session info: chrome=70.0.3538.102) 
>
>   (Driver info: chromedriver=2.41.578737 (
> 49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 
> SP1 x86_64) 
>
> ./features/support/pages/Frontend/Cotton_On/Thankyou_Page.rb:91:in 
> `find_dw_order_number' 
>
>
> ./features/step_definitions/Checkout_Page_steps.rb:1395:in `block (2 
> levels) in ' 
>
> ./features/step_definitions/Checkout_Page_steps.rb:1394:in `/^Thankyou 
> page is shown with details for the user$/' 
>
> ./features/Giftcards-AU.feature:233:in `Then Thankyou page is shown with 
> details for the user'
>
>  
>
> Sometimes
>
> Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {
> Alert text : Couldn't load credit card!}
>
>  
>
>   (Session info: chrome=70.0.3538.102) 
>
>   (Driver info: chromedriver=2.41.578737 
> (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
> x86_64)
>
>
>  
>
> In order for the dev to have a look I need to give them the browser 
> console logs at the point of failure. What happens is that some times I get 
> the error on "wait_for_ajax" and some time on "wait_and_click" method. The 
> test exits abruptly with the errors above and no screenshots ate taken
>
> Is there a way I can get the browser console logs at this point?
>
>
>
> def place_order
>  wait_for_ajax
>  wait_and_click place_order_btn_element
> end
>
>
> def wait_and_click element
>  begin
>  retries ||= 0
>  Watir::Wait.until {element}.focus
>  Watir::Wait.until {element}.click
>  rescue Selenium::WebDriver::Error::UnknownError
>  retry if (retries += 1) < $code_retry
>  rescue Watir::Exception::UnknownObjectException
>  retry if (retries += 1) < $code_retry
>  end
> end
>
>
>
>
>

-- 
-- 
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] Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {Alert text : Bad response - parser error!}

2018-12-04 Thread NaviHan
 Im having a tough time with this intermittent error I get on checkout page 
once all the details are filled and customer hits payment button.

Sometimes
Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {
Alert text : Bad response - parser error!}

 

  (Session info: chrome=70.0.3538.102) 

  (Driver info: chromedriver=2.41.578737 (
49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
x86_64) 

./features/support/pages/Frontend/Cotton_On/Thankyou_Page.rb:91:in 
`find_dw_order_number' 


./features/step_definitions/Checkout_Page_steps.rb:1395:in `block (2 levels) 
in ' 

./features/step_definitions/Checkout_Page_steps.rb:1394:in `/^Thankyou page 
is shown with details for the user$/' 

./features/Giftcards-AU.feature:233:in `Then Thankyou page is shown with 
details for the user'

 

Sometimes

Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: {
Alert text : Couldn't load credit card!}

 

  (Session info: chrome=70.0.3538.102) 

  (Driver info: chromedriver=2.41.578737 
(49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 
x86_64)


 

In order for the dev to have a look I need to give them the browser console 
logs at the point of failure. What happens is that some times I get the 
error on "wait_for_ajax" and some time on "wait_and_click" method. The test 
exits abruptly with the errors above and no screenshots ate taken

Is there a way I can get the browser console logs at this point?



def place_order
 wait_for_ajax
 wait_and_click place_order_btn_element
end


def wait_and_click element
 begin
 retries ||= 0
 Watir::Wait.until {element}.focus
 Watir::Wait.until {element}.click
 rescue Selenium::WebDriver::Error::UnknownError
 retry if (retries += 1) < $code_retry
 rescue Watir::Exception::UnknownObjectException
 retry if (retries += 1) < $code_retry
 end
end




-- 
-- 
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: Issue with watir index or Am I doing something wrong

2018-11-25 Thread NaviHan
Hi Justin

I cant remember what I did wrong with the collection, Im pretty sure I used 
"

applied_gift_cards_elements[index.to_i].div_element(:index => 0).text"


Anyways this absolutely works fine now.
Thanks a lot :-)

On Friday, 23 November 2018 13:06:07 UTC+11, NaviHan wrote:
>
> Having trouble using index.
>
> I have a section of a page as below.
> 
> 
> Card
> Amount Taken
> 
>  ="display: flex;">
> ...163867647149
> $20.00
> 
>  data-gcid="2790030163867647149">
> 
> 
> 
> 
> 
>  style="display: flex;">
> ...169169063156
> $25.90
> 
> ($74.10 left on card)
> 
> 
> 
>  data-gcid="2790030169169063156">
>  >
> 
> 
> 
> 
> 
>
>
> The pageobject is defined as
>
> div(:applied_gift_cards, :class => 'gc-list')
>
>
>
>
> And Im trying to access "...163867647149 " and "$20.00" as which gave 
> error
>
> return applied_gift_cards_element.div_element(:index => 1).div_element(:index 
> =>0).text
>
> return applied_gift_cards_element.div_element(:index => 1).div_element(:index 
> =>0).text
>
> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
> waiting for #"gc-list", 
> :tag_name=>"div"} --> {:index=>1, :tag_name=>"div"} --> {:index=>0, 
> :tag_name=>"div"}> to be located
>
> When printing the same element actually prints the Pageobect
> puts applied_gift_cards_element.div_element(:index => 1).div_element(:index 
> =>0)
> #
>
>
> A puts of the following printed as below which is again confusing
>
> puts applied_gift_cards_element.div_element(:index => 0).inner_html
> puts applied_gift_cards_element.div_element(:index => 1).inner_html
> puts applied_gift_cards_element.div_element(:index => 2).inner_html
> puts applied_gift_cards_element.div_element(:index => 3).inner_html
>
> Card
>  Amount Taken
> Card
> Amount Taken
> ...163867647149$20.00 type="button" class="remove-gift-cert pointer" 
> data-gcid="2790030163867647149">
>
>
>
>
> Am I doing something wrong here?
>
>

-- 
-- 
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: Issue with watir index or Am I doing something wrong

2018-11-23 Thread NaviHan
Hi Justin

The collection was the first thing I tried. But the issue is when there is 
only one gift card applied, meaning only one div with class 
> Having trouble using index.
>
> I have a section of a page as below.
> 
> 
> Card
> Amount Taken
> 
>  ="display: flex;">
> ...163867647149
> $20.00
> 
>  data-gcid="2790030163867647149">
> 
> 
> 
> 
> 
>  style="display: flex;">
> ...169169063156
> $25.90
> 
> ($74.10 left on card)
> 
> 
> 
>  data-gcid="2790030169169063156">
>  >
> 
> 
> 
> 
> 
>
>
> The pageobject is defined as
>
> div(:applied_gift_cards, :class => 'gc-list')
>
>
>
>
> And Im trying to access "...163867647149 " and "$20.00" as which gave 
> error
>
> return applied_gift_cards_element.div_element(:index => 1).div_element(:index 
> =>0).text
>
> return applied_gift_cards_element.div_element(:index => 1).div_element(:index 
> =>0).text
>
> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
> waiting for #"gc-list", 
> :tag_name=>"div"} --> {:index=>1, :tag_name=>"div"} --> {:index=>0, 
> :tag_name=>"div"}> to be located
>
> When printing the same element actually prints the Pageobect
> puts applied_gift_cards_element.div_element(:index => 1).div_element(:index 
> =>0)
> #
>
>
> A puts of the following printed as below which is again confusing
>
> puts applied_gift_cards_element.div_element(:index => 0).inner_html
> puts applied_gift_cards_element.div_element(:index => 1).inner_html
> puts applied_gift_cards_element.div_element(:index => 2).inner_html
> puts applied_gift_cards_element.div_element(:index => 3).inner_html
>
> Card
>  Amount Taken
> Card
> Amount Taken
> ...163867647149$20.00 type="button" class="remove-gift-cert pointer" 
> data-gcid="2790030163867647149">
>
>
>
>
> Am I doing something wrong here?
>
>

-- 
-- 
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: Issue with watir index or Am I doing something wrong

2018-11-22 Thread NaviHan
Oops my understanding was wrong here :-(

I can achieve this by using 

return applied_gift_cards_element.children[index.to_i].children[0].text

Is there a a better way?


On Friday, 23 November 2018 13:06:07 UTC+11, NaviHan wrote:
>
> Having trouble using index.
>
> I have a section of a page as below.
> 
> 
> Card
> Amount Taken
> 
>  ="display: flex;">
> ...163867647149
> $20.00
> 
>  data-gcid="2790030163867647149">
> 
> 
> 
> 
> 
>  style="display: flex;">
> ...169169063156
> $25.90
> 
> ($74.10 left on card)
> 
> 
> 
>  data-gcid="2790030169169063156">
>  >
> 
> 
> 
> 
> 
>
>
> The pageobject is defined as
>
> div(:applied_gift_cards, :class => 'gc-list')
>
>
>
>
> And Im trying to access "...163867647149 " and "$20.00" as which gave 
> error
>
> return applied_gift_cards_element.div_element(:index => 1).div_element(:index 
> =>0).text
>
> return applied_gift_cards_element.div_element(:index => 1).div_element(:index 
> =>0).text
>
> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
> waiting for #"gc-list", 
> :tag_name=>"div"} --> {:index=>1, :tag_name=>"div"} --> {:index=>0, 
> :tag_name=>"div"}> to be located
>
> When printing the same element actually prints the Pageobect
> puts applied_gift_cards_element.div_element(:index => 1).div_element(:index 
> =>0)
> #
>
>
> A puts of the following printed as below which is again confusing
>
> puts applied_gift_cards_element.div_element(:index => 0).inner_html
> puts applied_gift_cards_element.div_element(:index => 1).inner_html
> puts applied_gift_cards_element.div_element(:index => 2).inner_html
> puts applied_gift_cards_element.div_element(:index => 3).inner_html
>
> Card
>  Amount Taken
> Card
> Amount Taken
> ...163867647149$20.00 type="button" class="remove-gift-cert pointer" 
> data-gcid="2790030163867647149">
>
>
>
>
> Am I doing something wrong here?
>
>

-- 
-- 
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] Issue with watir index or Am I doing something wrong

2018-11-22 Thread NaviHan
Having trouble using index.

I have a section of a page as below.


Card
Amount Taken


...163867647149
$20.00








...169169063156
$25.90

($74.10 left on card)












The pageobject is defined as

div(:applied_gift_cards, :class => 'gc-list')




And Im trying to access "...163867647149 " and "$20.00" as which gave error

return applied_gift_cards_element.div_element(:index => 1).div_element(:index 
=>0).text

return applied_gift_cards_element.div_element(:index => 1).div_element(:index 
=>0).text

Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
waiting for #"gc-list", 
:tag_name=>"div"} --> {:index=>1, :tag_name=>"div"} --> {:index=>0, 
:tag_name=>"div"}> to be located

When printing the same element actually prints the Pageobect
puts applied_gift_cards_element.div_element(:index => 1).div_element(:index 
=>0)
#


A puts of the following printed as below which is again confusing

puts applied_gift_cards_element.div_element(:index => 0).inner_html
puts applied_gift_cards_element.div_element(:index => 1).inner_html
puts applied_gift_cards_element.div_element(:index => 2).inner_html
puts applied_gift_cards_element.div_element(:index => 3).inner_html

Card
 Amount Taken
Card
Amount Taken
...163867647149$20.00




Am I doing something wrong here?

-- 
-- 
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] Hiddenfield, Is there a limitation in PageObject

2018-10-24 Thread NaviHan
Found this really confusing behavior while dealing with this element. 
Basically I want to get the value





I have declared the pageobect as below

hidden_fields(:test, :name => 'pid')


And trying to print the value actually prints the pageobject instead of the 
value.

puts test_elements.find {|el| el.value}

#


So I did a "value.value" and Watir complained as
NoMethodError: undefined method `value' for "9351785586540":String

Any clue why this strange behavior. Is this a limitation of PageObject?


-- 
-- 
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: How to handle behavior while pop up loads, is sleep is the only solution?

2018-10-02 Thread NaviHan
Hi Justin

This works fine and I have ran the script multiple times and it passed. 
This is configured to run on Jenkins Boxes. Waiting for overnight results.
As a related question.

We use the below code for the pop up to load completely. I have a 
verification to be done after the pop up has completely disappeared.

I know we need to do wait_while but how do we combine s.present? && s.style(
'overflow') == 'visible' to evaluate to false ?

Cheers



On Tuesday, 25 September 2018 14:41:15 UTC+10, NaviHan wrote:
>
> Its been some days I found this issue untill I understood today the cause 
> of failure.
>
> The behavior is
> a. The user enters the email on check out page
> b. A pop up skids in from the top of the page
> c. The user clicks a "continue as guest "button on the pop up
> d. The pop up skids back in and disappears
> e. Verify the pop up disappeared
>
> The issue is between step b and step c there is a time when the pop up is 
> sliding into the page until its loaded completely. During this time the 
> script clicks the dismiss button. Because the pop hasent completed loading 
> the click doesn't make it disappear.
>
> Similarly becasue the pop up takes time to slide back and disapper the 
> check at step e fails.
>
> For the time being Im working around this issue with sleeps. But is there 
> a neater way?
>
>
> The pop up is defined as 
>
> button(:continue_as_guest, :class => ['button', 'close-dialog-button'])
>
>
> The code that does the job is 
>
> def continue_as_guest
>   continue_as_guest_element.wait_until(&:present?).click
> end
>
>
> After sleep, which works fine
>
> def continue_as_guest
>   sleep 5
>   continue_as_guest_element.wait_until(&:present?).click
>   sleep 5
> end
>
>
> Note:- I have also tried to wait_while(&:present?) still the issue stays 
> the same
>
> def continue_as_guest
>   
> continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
> end
>
>
>
>

-- 
-- 
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: How to handle behavior while pop up loads, is sleep is the only solution?

2018-09-26 Thread NaviHan
Hi Justin/Titus

Trying to understand the overflow attribute in style sheet

When the pop up is not present the oveflow property is there unser style as 
shown here
https://i.imgur.com/X1MxiHD.png

When the popup is fully loaded its the same.

https://i.imgur.com/xu5E3mp.png

So what does this mean, s.style('overflow') == 'visible', and where can we 
verify that 




On Tuesday, 25 September 2018 14:41:15 UTC+10, NaviHan wrote:
>
> Its been some days I found this issue untill I understood today the cause 
> of failure.
>
> The behavior is
> a. The user enters the email on check out page
> b. A pop up skids in from the top of the page
> c. The user clicks a "continue as guest "button on the pop up
> d. The pop up skids back in and disappears
> e. Verify the pop up disappeared
>
> The issue is between step b and step c there is a time when the pop up is 
> sliding into the page until its loaded completely. During this time the 
> script clicks the dismiss button. Because the pop hasent completed loading 
> the click doesn't make it disappear.
>
> Similarly becasue the pop up takes time to slide back and disapper the 
> check at step e fails.
>
> For the time being Im working around this issue with sleeps. But is there 
> a neater way?
>
>
> The pop up is defined as 
>
> button(:continue_as_guest, :class => ['button', 'close-dialog-button'])
>
>
> The code that does the job is 
>
> def continue_as_guest
>   continue_as_guest_element.wait_until(&:present?).click
> end
>
>
> After sleep, which works fine
>
> def continue_as_guest
>   sleep 5
>   continue_as_guest_element.wait_until(&:present?).click
>   sleep 5
> end
>
>
> Note:- I have also tried to wait_while(&:present?) still the issue stays 
> the same
>
> def continue_as_guest
>   
> continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
> end
>
>
>
>

-- 
-- 
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: How to handle behavior while pop up loads, is sleep is the only solution?

2018-09-25 Thread NaviHan
Hi Titus & Justin

My theory of actually clicking the button before the pop is fully loaded 
could be wrong, because even if its not fully loaded the click on "continue 
as guest" should dismiss the popup.

Please see the video here 

https://drive.google.com/file/d/1ycWdST29FptgOS5GYDfRuAPUVBfeQt3h/view?usp=sharing

But what made me think that the button is actually clicked is the 
screenshot taken at the point of failure, which has a highlighter around 
the "continue as guest" button which indicated the button is clicked.

https://i.imgur.com/TdhYPz4.png

Both are contradictory.

What do you think?


On Tuesday, 25 September 2018 14:41:15 UTC+10, NaviHan wrote:
>
> Its been some days I found this issue untill I understood today the cause 
> of failure.
>
> The behavior is
> a. The user enters the email on check out page
> b. A pop up skids in from the top of the page
> c. The user clicks a "continue as guest "button on the pop up
> d. The pop up skids back in and disappears
> e. Verify the pop up disappeared
>
> The issue is between step b and step c there is a time when the pop up is 
> sliding into the page until its loaded completely. During this time the 
> script clicks the dismiss button. Because the pop hasent completed loading 
> the click doesn't make it disappear.
>
> Similarly becasue the pop up takes time to slide back and disapper the 
> check at step e fails.
>
> For the time being Im working around this issue with sleeps. But is there 
> a neater way?
>
>
> The pop up is defined as 
>
> button(:continue_as_guest, :class => ['button', 'close-dialog-button'])
>
>
> The code that does the job is 
>
> def continue_as_guest
>   continue_as_guest_element.wait_until(&:present?).click
> end
>
>
> After sleep, which works fine
>
> def continue_as_guest
>   sleep 5
>   continue_as_guest_element.wait_until(&:present?).click
>   sleep 5
> end
>
>
> Note:- I have also tried to wait_while(&:present?) still the issue stays 
> the same
>
> def continue_as_guest
>   
> continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
> end
>
>
>
>

-- 
-- 
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] How to handle behavior while pop up loads, is sleep is the only solution?

2018-09-24 Thread NaviHan
Its been some days I found this issue untill I understood today the cause 
of failure.

The behavior is
a. The user enters the email on check out page
b. A pop up skids in from the top of the page
c. The user clicks a "continue as guest "button on the pop up
d. The pop up skids back in and disappears
e. Verify the pop up disappeared

The issue is between step b and step c there is a time when the pop up is 
sliding into the page until its loaded completely. During this time the 
script clicks the dismiss button. Because the pop hasent completed loading 
the click doesn't make it disappear.

Similarly becasue the pop up takes time to slide back and disapper the 
check at step e fails.

For the time being Im working around this issue with sleeps. But is there a 
neater way?


The pop up is defined as 

button(:continue_as_guest, :class => ['button', 'close-dialog-button'])


The code that does the job is 

def continue_as_guest
  continue_as_guest_element.wait_until(&:present?).click
end


After sleep, which works fine

def continue_as_guest
  sleep 5
  continue_as_guest_element.wait_until(&:present?).click
  sleep 5
end


Note:- I have also tried to wait_while(&:present?) still the issue stays 
the same

def continue_as_guest
  
continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
end



-- 
-- 
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: How to take full screen, screenshots after test fails

2018-09-24 Thread NaviHan
Hi Sam

Issue resolved. It was basically the issue with PATH variable for Jenkins 
job.

"convert.exe" is also the name of a windows executable which converts FAT 
filesystem to NTFS. When you do not specify the full path of an executable

the system first searches the current working directory and then searches 
the path environment variable, examining each directory from left to right, 
looking for an executable filename that matches the command name given.

"C:\Windows\System32" is generally present in the beginning of %PATH% 
variable, causing the Windows convert utility to launch, which fails with 
"Invalid Parameter" error as expected.

As a workaround, I just modified the order of PATH variable as


SET "PATH=C:\Program Files\ImageMagick-6.9.10-Q8;%PATH%;C:\Ruby24-x64\bin"


Good God!!!

On Thursday, 20 September 2018 21:14:17 UTC+10, NaviHan wrote:
>
> Hi 
>
> I have put this code in the hooks which takes scresnshot when a test 
> fails. The issue is that Im not getting the full browser screen. Its chops 
> off at the bottom
>
> After do |scenario|
>  take_screenshot(@browser, scenario)
> end
>
>
> 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
>
>
> By the way my before hooks looks like this.
>
> Before do|scenario|
> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
> @browser.goto "https://www.sandbox.paypal.com;
> @browser.cookies.clear
> @browser.goto "https://portal-sandbox.afterpay.com;
> @browser.cookies.clear
> @browser.goto "https://i-pay.co.za;
> @browser.cookies.clear
> @browser.goto("ci.XXX.com/")
> @browser.window.maximize
> @browser.driver.manage.timeouts.implicit_wait = 0
> @browser.cookies.clear
> @browser.driver.manage.window.maximize
> PageObject.default_element_wait=(10)
> PageObject.javascript_framework = :jquery
> end #before scenario
>
>
>
>

-- 
-- 
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: How to take full screen, screenshots after test fails

2018-09-24 Thread NaviHan
A more readable format of the error


`convert -size 1920x1957 xc:white ./screenshots/Button Function  Checkout with 
an email address without a website account  without PERKS membership hit   
Continue As Guest _failure_2018-09-24_1712.png` failed with error:
Invalid Parameter - 1920x1957
 (MiniMagick::Error)
./features/support/hooks.rb:86:in `take_screenshot'
./features/support/hooks.rb:71:in `After'


On Thursday, 20 September 2018 21:14:17 UTC+10, NaviHan wrote:
>
> Hi 
>
> I have put this code in the hooks which takes scresnshot when a test 
> fails. The issue is that Im not getting the full browser screen. Its chops 
> off at the bottom
>
> After do |scenario|
>  take_screenshot(@browser, scenario)
> end
>
>
> 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
>
>
> By the way my before hooks looks like this.
>
> Before do|scenario|
> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
> @browser.goto "https://www.sandbox.paypal.com;
> @browser.cookies.clear
> @browser.goto "https://portal-sandbox.afterpay.com;
> @browser.cookies.clear
> @browser.goto "https://i-pay.co.za;
> @browser.cookies.clear
> @browser.goto("ci.XXX.com/")
> @browser.window.maximize
> @browser.driver.manage.timeouts.implicit_wait = 0
> @browser.cookies.clear
> @browser.driver.manage.window.maximize
> PageObject.default_element_wait=(10)
> PageObject.javascript_framework = :jquery
> end #before scenario
>
>
>
>

-- 
-- 
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: How to take full screen, screenshots after test fails

2018-09-24 Thread NaviHan
Hi Sam

Im getting this weird error when running the script on Jenkins box. Its a 
machine of AWS. Any clue?

 [
31m features/Loyalty_Memberships-AU.feature:189:in `And the perks overlay popup 
closes' [0m 2018-09-24 16:11:50 WARN Watir Screenshot Stitch [DEPRECATION] 
Passing the browser is deprecated and will no longer work in version 0.7.0 
/lib/watir-screenshot-stitch.rb:31  [31m `convert -size 1920x1957 xc:white 
./screenshots/Button Function Checkout with an email address without a website 
account without PERKS membership hit Continue As Guest 
_failure_2018-09-24_1611.png` failed with error: [0m  [31m Invalid Parameter - 
1920x1957  [0m  [31m (MiniMagick::Error) [0m  [31m 
./features/support/hooks.rb:86:in `take_screenshot' [0m  [31m 
./features/support/hooks.rb:71:in `After' [0m  [36mScenario Failed ! [0m



On Thursday, 20 September 2018 21:14:17 UTC+10, NaviHan wrote:
>
> Hi 
>
> I have put this code in the hooks which takes scresnshot when a test 
> fails. The issue is that Im not getting the full browser screen. Its chops 
> off at the bottom
>
> After do |scenario|
>  take_screenshot(@browser, scenario)
> end
>
>
> 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
>
>
> By the way my before hooks looks like this.
>
> Before do|scenario|
> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
> @browser.goto "https://www.sandbox.paypal.com;
> @browser.cookies.clear
> @browser.goto "https://portal-sandbox.afterpay.com;
> @browser.cookies.clear
> @browser.goto "https://i-pay.co.za;
> @browser.cookies.clear
> @browser.goto("ci.XXX.com/")
> @browser.window.maximize
> @browser.driver.manage.timeouts.implicit_wait = 0
> @browser.cookies.clear
> @browser.driver.manage.window.maximize
> PageObject.default_element_wait=(10)
> PageObject.javascript_framework = :jquery
> end #before scenario
>
>
>
>

-- 
-- 
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: How to take full screen, screenshots after test fails

2018-09-21 Thread NaviHan
Hi Sam

Just found this warning
2018-09-21 20:32:17 WARN Watir Screenshot Stitch [DEPRECATION] Passing the 
browser is deprecated and will no longer work in version 0.7.0 /lib/watir-
screenshot-stitch.rb:31


In fact I did try using version 0.7.0 of ImageMagick, but found this issue 
mentioned in this thread (issue with convert command) 
--> 
https://stackoverflow.com/questions/38163849/imagemagick-issue-with-windows-and-convert-function

So I reverted to 6.9

But aren't we supposed to pass browser as mentioned in the previous reply?

Cheers
Navi

On Thursday, 20 September 2018 21:14:17 UTC+10, NaviHan wrote:
>
> Hi 
>
> I have put this code in the hooks which takes scresnshot when a test 
> fails. The issue is that Im not getting the full browser screen. Its chops 
> off at the bottom
>
> After do |scenario|
>  take_screenshot(@browser, scenario)
> end
>
>
> 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
>
>
> By the way my before hooks looks like this.
>
> Before do|scenario|
> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
> @browser.goto "https://www.sandbox.paypal.com;
> @browser.cookies.clear
> @browser.goto "https://portal-sandbox.afterpay.com;
> @browser.cookies.clear
> @browser.goto "https://i-pay.co.za;
> @browser.cookies.clear
> @browser.goto("ci.XXX.com/")
> @browser.window.maximize
> @browser.driver.manage.timeouts.implicit_wait = 0
> @browser.cookies.clear
> @browser.driver.manage.window.maximize
> PageObject.default_element_wait=(10)
> PageObject.javascript_framework = :jquery
> end #before scenario
>
>
>
>

-- 
-- 
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: Maybe look in an iframe? error when clicking button

2018-09-21 Thread NaviHan
Hi Justin and Titus

tap(&:click) did the trick

Now its successfully removing the second voucher as well

Thanks for the detailed explanation.. 

Cheers
Navi

-- 
-- 
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: How to take full screen, screenshots after test fails

2018-09-21 Thread NaviHan
Hi Titus and Sam

This worked like a charm. Such a very usefull gem. Thanks a ton.
I just prepared a wiki for my project. Pasting here in case if this helps.

*For capturing full screen images*

Use gem https://github.com/samnissen/watir-screenshot-stitch
Include in Gemfile

gem 'watir-screenshot-stitch'
gem "mini_magick"
Run bundle installInstall "ImageMagick" exe on host machine

The host machine should have "ImageMagick" intsalled

The windows exe can be downloaded from 
https://www.imagemagick.org/download/binaries/

Recommeneded:- ImageMagick-6.9.10-11-Q8-x64-dll
Verify Installation

Select “Command Prompt” from the Windows Start menu. Within the window type

convert logo: logo.miff
imdisplay logo.miff

and the ImageMagick logo should be displayed in a window. 
Usage

browser = Watir::Browser.new :chrome, options: {args: args}

opts = {:page_height_limit => 5000}

screenshot_path =  "#{scenario_name}" + "_failure_" + time

@browser.screenshot.save_stitch(screenshot_path, browser, opts)


On Thursday, 20 September 2018 21:14:17 UTC+10, NaviHan wrote:
>
> Hi 
>
> I have put this code in the hooks which takes scresnshot when a test 
> fails. The issue is that Im not getting the full browser screen. Its chops 
> off at the bottom
>
> After do |scenario|
>  take_screenshot(@browser, scenario)
> end
>
>
> 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
>
>
> By the way my before hooks looks like this.
>
> Before do|scenario|
> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
> @browser.goto "https://www.sandbox.paypal.com;
> @browser.cookies.clear
> @browser.goto "https://portal-sandbox.afterpay.com;
> @browser.cookies.clear
> @browser.goto "https://i-pay.co.za;
> @browser.cookies.clear
> @browser.goto("ci.XXX.com/")
> @browser.window.maximize
> @browser.driver.manage.timeouts.implicit_wait = 0
> @browser.cookies.clear
> @browser.driver.manage.window.maximize
> PageObject.default_element_wait=(10)
> PageObject.javascript_framework = :jquery
> end #before scenario
>
>
>
>

-- 
-- 
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: How to take full screen, screenshots after test fails

2018-09-20 Thread NaviHan
Hi Sam

Thanks for reaching out. I will try that out tomorrow from office. Will let 
you know the outcome :-)

On Thursday, 20 September 2018 21:14:17 UTC+10, NaviHan wrote:
>
> Hi 
>
> I have put this code in the hooks which takes scresnshot when a test 
> fails. The issue is that Im not getting the full browser screen. Its chops 
> off at the bottom
>
> After do |scenario|
>  take_screenshot(@browser, scenario)
> end
>
>
> 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
>
>
> By the way my before hooks looks like this.
>
> Before do|scenario|
> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
> @browser.goto "https://www.sandbox.paypal.com;
> @browser.cookies.clear
> @browser.goto "https://portal-sandbox.afterpay.com;
> @browser.cookies.clear
> @browser.goto "https://i-pay.co.za;
> @browser.cookies.clear
> @browser.goto("ci.XXX.com/")
> @browser.window.maximize
> @browser.driver.manage.timeouts.implicit_wait = 0
> @browser.cookies.clear
> @browser.driver.manage.window.maximize
> PageObject.default_element_wait=(10)
> PageObject.javascript_framework = :jquery
> end #before scenario
>
>
>
>

-- 
-- 
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: Maybe look in an iframe? error when clicking button

2018-09-20 Thread NaviHan
Ok, Titus, but why use click on self?
Just searched the web for documentation on tap, couldnt find it.

Could you please point me to if any?

On Thursday, 20 September 2018 20:50:21 UTC+10, NaviHan wrote:
>
> I have a bag page where I have applied two coupons. Once the coupons are 
> applied the source looks like this
> 
>
>
> Applied codes:
>
> 
> 
> 
> 9840150120702065
> 
> 
> 
>  "delete-coupon">
> 
> Remove
> 
> 
> 
>
>
> 
> 
> 
> autotest_order
> 
> 
> 
>  "delete-coupon">
> 
> Remove
> 
> 
> 
>
> 
>
>
>
> There is a remove link(button) against each coupon. Basically my test 
> clicks these buttons to remove them
>
> I have the page object defined as and the step def and method as follows
>
> buttons(:delete_coupon, :id => 'delete-coupon')
>
>
>
>
> And(/^the customer removes the coupons\/vouchers from Bag Page$/) do |
> table|
>   on(MybagPage) do |page|
> @remove_voucher_list = table.hashes
> @remove_voucher_list.each {|data|
>   page.remove_voucher_from_bag data['voucher_id']
> }
>   end
>
>
> def remove_voucher_from_bag coupon_id
>   delete_coupon_elements.find{|el| el.value.to_s == coupon_id.to_s}.click
> end
>
>
> The script removes the coupon "9840150120702065", but when trying to 
> remove the next coupon fails with folowing message
> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
> waiting for #"delete-coupon", 
> :tag_name=>"button", :index=>1}> to be located; Maybe look in an iframe?
> ./features/support/pages/Frontend/Cotton_On/Mybag_Page.rb:141:in `block 
> in remove_voucher_from_bag'
>
>
>
> Any clue whats missing here?
>

-- 
-- 
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: Maybe look in an iframe? error when clicking button

2018-09-20 Thread NaviHan
Sure Justin, Let me try that

But what does tap(&:click)do?

On Thursday, 20 September 2018 20:50:21 UTC+10, NaviHan wrote:

> I have a bag page where I have applied two coupons. Once the coupons are 
> applied the source looks like this
> 
>
>
> Applied codes:
>
> 
> 
> 
> 9840150120702065
> 
> 
> 
>  "delete-coupon">
> 
> Remove
> 
> 
> 
>
>
> 
> 
> 
> autotest_order
> 
> 
> 
>  "delete-coupon">
> 
> Remove
> 
> 
> 
>
> 
>
>
>
> There is a remove link(button) against each coupon. Basically my test 
> clicks these buttons to remove them
>
> I have the page object defined as and the step def and method as follows
>
> buttons(:delete_coupon, :id => 'delete-coupon')
>
>
>
>
> And(/^the customer removes the coupons\/vouchers from Bag Page$/) do |
> table|
>   on(MybagPage) do |page|
> @remove_voucher_list = table.hashes
> @remove_voucher_list.each {|data|
>   page.remove_voucher_from_bag data['voucher_id']
> }
>   end
>
>
> def remove_voucher_from_bag coupon_id
>   delete_coupon_elements.find{|el| el.value.to_s == coupon_id.to_s}.click
> end
>
>
> The script removes the coupon "9840150120702065", but when trying to 
> remove the next coupon fails with folowing message
> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
> waiting for #"delete-coupon", 
> :tag_name=>"button", :index=>1}> to be located; Maybe look in an iframe?
> ./features/support/pages/Frontend/Cotton_On/Mybag_Page.rb:141:in `block 
> in remove_voucher_from_bag'
>
>
>
> Any clue whats missing here?
>

-- 
-- 
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: Maybe look in an iframe? error when clicking button

2018-09-20 Thread NaviHan
Hi Justin

The button collection is defined as

buttons(:delete_coupon, :id => 'delete-coupon')


On Thursday, 20 September 2018 20:50:21 UTC+10, NaviHan wrote:
>
> I have a bag page where I have applied two coupons. Once the coupons are 
> applied the source looks like this
> 
>
>
> Applied codes:
>
> 
> 
> 
> 9840150120702065
> 
> 
> 
>  "delete-coupon">
> 
> Remove
> 
> 
> 
>
>
> 
> 
> 
> autotest_order
> 
> 
> 
>  "delete-coupon">
> 
> Remove
> 
> 
> 
>
> 
>
>
>
> There is a remove link(button) against each coupon. Basically my test 
> clicks these buttons to remove them
>
> I have the page object defined as and the step def and method as follows
>
> buttons(:delete_coupon, :id => 'delete-coupon')
>
>
>
>
> And(/^the customer removes the coupons\/vouchers from Bag Page$/) do |
> table|
>   on(MybagPage) do |page|
> @remove_voucher_list = table.hashes
> @remove_voucher_list.each {|data|
>   page.remove_voucher_from_bag data['voucher_id']
> }
>   end
>
>
> def remove_voucher_from_bag coupon_id
>   delete_coupon_elements.find{|el| el.value.to_s == coupon_id.to_s}.click
> end
>
>
> The script removes the coupon "9840150120702065", but when trying to 
> remove the next coupon fails with folowing message
> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
> waiting for #"delete-coupon", 
> :tag_name=>"button", :index=>1}> to be located; Maybe look in an iframe?
> ./features/support/pages/Frontend/Cotton_On/Mybag_Page.rb:141:in `block 
> in remove_voucher_from_bag'
>
>
>
> Any clue whats missing here?
>

-- 
-- 
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] How to take full screen, screenshots after test fails

2018-09-20 Thread NaviHan
Hi 

I have put this code in the hooks which takes scresnshot when a test fails. 
The issue is that Im not getting the full browser screen. Its chops off at 
the bottom

After do |scenario|
 take_screenshot(@browser, scenario)
end


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


By the way my before hooks looks like this.

Before do|scenario|
ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
@browser.goto "https://www.sandbox.paypal.com;
@browser.cookies.clear
@browser.goto "https://portal-sandbox.afterpay.com;
@browser.cookies.clear
@browser.goto "https://i-pay.co.za;
@browser.cookies.clear
@browser.goto("ci.XXX.com/")
@browser.window.maximize
@browser.driver.manage.timeouts.implicit_wait = 0
@browser.cookies.clear
@browser.driver.manage.window.maximize
PageObject.default_element_wait=(10)
PageObject.javascript_framework = :jquery
end #before scenario



-- 
-- 
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] Maybe look in an iframe? error when clicking button

2018-09-20 Thread NaviHan
I have a bag page where I have applied two coupons. Once the coupons are 
applied the source looks like this



Applied codes:




9840150120702065





Remove








autotest_order





Remove








There is a remove link(button) against each coupon. Basically my test 
clicks these buttons to remove them

I have the page object defined as and the step def and method as follows

buttons(:delete_coupon, :id => 'delete-coupon')




And(/^the customer removes the coupons\/vouchers from Bag Page$/) do |table|
  on(MybagPage) do |page|
@remove_voucher_list = table.hashes
@remove_voucher_list.each {|data|
  page.remove_voucher_from_bag data['voucher_id']
}
  end


def remove_voucher_from_bag coupon_id
  delete_coupon_elements.find{|el| el.value.to_s == coupon_id.to_s}.click
end


The script removes the coupon "9840150120702065", but when trying to remove 
the next coupon fails with folowing message
Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
waiting for #"delete-coupon", 
:tag_name=>"button", :index=>1}> to be located; Maybe look in an iframe?
./features/support/pages/Frontend/Cotton_On/Mybag_Page.rb:141:in `block in 
remove_voucher_from_bag'



Any clue whats missing here?

-- 
-- 
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: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Got you, Titus
The fundamental aspects are clear now.

I will get back if I find a real case in my project that is not working as 
per my understanding

Thanks a million for taking time to clarify things. really appreciate it :-)

Cheers
Navi

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Oh no Titus. Havent encountered such a scenario in my project.
I just wanted to make my understanding clear.

Except this dynamic "here" thingy everything regarding Watir waits is clear 
now.. :-)

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Hi Titus

Let me explain in deatils

We define the selector in the code as
div(class: "here")



Dynamic action changed the class to 
"not-here"

in the DOM but but the the selector still remains the same in code
.(div(class: "here"))



Due to this reason 
element.wait_while(&:present?)

,will timeout as Watir just keeps verifying that the cached element is 
still there using the selector defined in code which is again
 (div(class: "here"))


As a solution we use 
element.wait_while_present 

which looks up the element from scratch.. But the class of the element in 
DOM is still
 "not_here" 

and the selector in code is
 "here"


So element.wait_while_present is never going to locate the element as the 
class has changed to
 "not-here" 

in DOM.

But if in the DOM the class has changed back to 
"here"

from 
"not-here"

then
 wait_while_present

will locate it.

I hope you see where the confusion is. We never talks about the dynamic 
action which changes the class back to "here"


On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:

> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Hi Titus

This statement

These are effectively equivalent because it is ignoring cache:

my_element.wait_while_present
browser.element(class: 'here').wait_while(&:present)


Do you mean wait_while_present = wait_while(&:present)  --> "present 
without question mark"

To conclude

wait_while_present will successfully wait when the class transition as 
"here" to "not-here" to "here"

Cheers

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Yes Titus, I got that.

But for that fresh retry from scratch to work, the class of the element has 
to go back to "here" from "not-here" isnt it?

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-13 Thread NaviHan
Thanks a lot Titus and Rajagopalan.

I want to wrap this up with one more question about wait_while_present. Had 
this confusion while reading Titus's article on Watir waits 
(http://watir.com/guides/waiting/)

you have this element, Foo and you locate it with 
code "element = browser.div(class: "here")"

Some dynamic event caused the element class to change: "Foo"

In this case we want the element to be looked up from scratch during the 
polling, which is what this does:

element.wait_while_present

But my question is becasue the class of the element has changed to 
"not-here" how the wait_while_present is going to work, basically the 
identifier has changed?

Or did you mean that the class has changed from "here" to "not-here" and 
again it changed back to "here" ??

Cheers
Navi

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-12 Thread NaviHan
Hi Titus

Thats makes it very clear now :-)

Just to confirm, action methods as in set, click, select
And the reading attribute values like id, text, or any other custom 
attribute are not auto covered and we need to use wait_until(&:present?)

Is that correct?

Cheers
Navi

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-12 Thread NaviHan
Hi Titus

Thanks for the detailed explanation and the documentation link. 
Unfortunately my confusion doesnt get clarified.

As you said for an element which eventually displays, for example a pop up 
that appears due to a user action, we can read the text by

*scenario 1*
"my_element.when_present.text" because when_present get info from element 
that eventually *displays*

The above changed to my_element.text, post Watir6.0 as the wait was made 
automatic

*scenario 2*
"my_element.wait_until(&:present?).text" also waits for the element to be 
displayed like "my_element.when_present.text"
So they are one and the same.

Because they are one and the same and post Watir6.0 the when_present wait 
was made automatic we can achieve the above objective with "my_element.text"

So there will never be a case where we have to use wait_until(&:present?).

This is my theory.
Is that correct?

Cheers
Navi


On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-11 Thread NaviHan

Hi Titus

You said "when_present" and 'wait_until(&:present?)" does the same thing, 
which is Waits for element to be present, the former is deprecated and 
latter is recommended.

Why is that if bot does the same thing

Im trying to understand if "wait_until(&:present?)" is in any ways 
different from "when_present" eventhough its deprecated.


Justin also mentioned on version 6.0 of Watir you made changes to 
automatically wait for elements before taking actions which let us do away 
ith "when_present". So I still do not understand why we should ever use 
wait_until(&:present?) at all.

Sorry if I sound stupid, becasue there is so much cinfusion around waits :-(

Cheers
Navi

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-11 Thread NaviHan
Sorry to too many replies. But this is really killing me. I see there is 
anothet wait which is wait_until_present?

Someone please clarify the difference between the 3

1. element.when_present, which is deprecated and auto included from watir 
6.0 onwards
2. element.wait_until(&:present) which is same as element.wait_until {|el 
el.present?)|}  &
3. element.wait_until_present

I have read that two is used when Watir.relaxed_locate = false  two but why 
would someone ever set this to true? which means watir doesnt wait for an 
element to be found or present before taking an action.

Thanks

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-11 Thread NaviHan
Hi Justin/Titus

I have read the watit 6.0 release notes and FAQ 
@ http://watir.com/watir-6-faq/#H
Thanks a lot for giving the valuable info.

Until now I was under the impression that "element.when_present" & 
"element.wait_until(&:present)", but reading the notes I understood that 
they are different.

Arent both waiting for deafult of "30" seconds for the element to be 
present? What is the difference between the two? 

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: How often to get element reference, best practice?

2018-09-11 Thread NaviHan
Hi Justin

Unfortunately thats not the truth. We started automation for our project 
approximately an year back, and Im pretty sure the version since the start 
is post 6.0.
We are doing these kind of duplication out of ignorance.

Coming to the question, does watir show any warnings if we use 
"add_to_bag_element.when_present.click" instead of "add_to_bag"?

And is the wait the default of 30 seconds?

Can you give an example where we have to explicitly wait?

Cheers

On Tuesday, 11 September 2018 14:52:33 UTC+10, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

-- 
-- 
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: Trouble reading the text from Popup , Using Watir and Pageobject

2018-09-10 Thread NaviHan
Hi guys

I wanted to give an update on this issue.

A lot had changed in the project which now gives a stable run.
The jenkins box was running slow because the Java SE binary was eating 90% 
of memory all the time. Once I killed and reinstalled it the tests are 
running at lightning speed.This has fixed a lot of issues.

With this pop up , the time it stays open was driven by a timer in the 
code. I have increased the timer and that gives the script enough time to 
read the text. I also found sometimes the scripts still fails to read the 
text, 1 out of 20 times. I suspect the focus is lost so Im thinking of 
making the focus to the pop up before reading the text.

With the above changes Im getting stable runs now.

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.


[wtr-general] wait_for_ajax method in PageObject gem, how to use in hooks?

2018-09-10 Thread NaviHan
We did discuss this previously. Im trying to find a way to use 
wait_for_ajax for each and every element.

Titus or Justin has earlier suggested to move this to the hooks.rb file.

Could you guys tell me how to use it in hooks?

-- 
-- 
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] How often to get element reference, best practice?

2018-09-10 Thread NaviHan
This is something that keeps me a bit sceptic when I write and read the 
automation code in my project.
This used PageObjects.

I have seen extensive use of element referces, for example 

button(:add_to_bag, :css => '#add-to-cart')
add_to_bag.element.when_present.click



instead of 

add_to_bag 

which directly clicks the element

I have also seen extensive use of referencing elements using 
.when_present, .wait_until_present etc

Im confused where we should draw the line when deciding to reference the 
element and actually using it(as in directly calling "add_o_bag" in the above 
example to click the element.

Any thoughts?


-- 
-- 
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: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-13 Thread NaviHan


All

Even javascript is failing with same reason. So this again passed in Local 
machine but failed with the same reason on the Jenkins box. WTF!!!

def rewards_popup_description
 #return cta_description_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/," ")
 return @browser.execute_script('return 
document.getElementsByClassName("homepage-clickactivate-popup")[0];').text.gsub(/[^$,.A-Za-z0-9]/,"
 ")

end

def rewards_popup_expiration
 #return cta_expiry_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/," ")
 return @browser.execute_script('return 
document.getElementsByClassName("expiration-days")[0];').text.gsub(/[^$,.A-Za-z0-9]/,"
 ")
end


 
expected "" to include "$10 reward activated" (RSpec::Expectations::
ExpectationNotMetError)
./features/step_definitions/Loyalty_steps.rb:9:in `block (2 levels) in '
./features/step_definitions/Loyalty_steps.rb:8:in `/^the customer sees the 
overlay popup message "([^"]*)"$/'
features/Loyalty-AU.feature:122:in `And the customer sees the overlay popup 
message "$10 reward activated"'



-- 
-- 
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: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-09 Thread NaviHan
I posted the issue in stackoverflow :-(
https://stackoverflow.com/questions/51777433/element-not-found-exception-in-jenkins-box-while-script-passing-in-local

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.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread NaviHan
Yes Titus. I took the screenshot as well.
It shows the homepage of the site, without the popup.
Basically the popup appears on the homepage for 10second(this is driven by 
config) and after 10 seconds it disappears. This is where we are trying to 
read the text of the popup.

The screenshot show the homepage without the popup...

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.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread NaviHan
 (3.7.0)
  * rspec-core (3.7.1)
  * rspec-expectations (3.7.0)
  * rspec-mocks (3.7.0)
  * rspec-support (3.7.1)
  * ruby-oci8 (2.2.5.1)
  * ruby-ole (1.2.12.1)
  * ruby-plsql (0.6.0)
  * ruby-rc4 (0.1.5)
  * rubyzip (1.2.1)
  * sauce_whisk (0.1.0)
  * saucelabs (0.5)
  * selenium-webdriver (3.13.1)
  * syntax (1.2.2)
  * thread_safe (0.3.6)
  * tzinfo (1.2.5)
  * unf (0.1.4)
  * unf_ext (0.0.7.5)
  * watir (6.12.0)
  * watir-scroll (0.2.0)
  * watir-webdriver (0.9.9)
  * yard (0.9.15)
  * yard-cucumber (4.0.0)
  * yml_reader (0.7)


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.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread NaviHan
Hi Titus

Thanks for taking time to clarify things. Really appreciate it.
In Fact I tried 
"cta_description_element.wait_until(&:present?).text.gsub(/[^$,.A-Za-z0-9]/," 
")" unfortunately that was also read as "", hence the confusion.
Let me try to run the script directly on Jenkins box, will post the outcome

I understood the difference between wait_while and wait_until.
The confusion is as explained below
browser.wait_while { false } # => returns immediately
While waiting for this to be false can the script do something? Othrwise 
does the below code makes sense? Script is waiting for the text to be empty 
, while waiting it has to read the content of the text...

 def rewards_popup_description
cta_description_element.wait_while do
  cta_description_element.text == ""
  return cta_description_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/," 
")
    end
  end




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.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread NaviHan
***Please ignore previous message. It was accidently sent before typing 
completely"

Hi Titus and Rajagopalan and Justin

The hook is written by another automation engineer, so Im yet to understand 
that fully.
Considering Im new to automation Im going through the learning curve and 
you guys are of immense help. 
Tomorrow I will be debugging the script in Jenkins box as to why reading 
the text from the popup fails just to remind this topic was started for 
that and in the midst we nailed the javascript issue. The confusion with 
wait_until and wait_while still bothers me.

Let me make it a bit more clearer to you.

1. The pop up appears and Im trying to assert two texts in that popup.
2. On local this passes but on Jenkins box the text is being read as empty

So Im thinking in the line, wait while the pop up disappears during that 
time read the texts in the pop up. I have this idea in mind but dont know 
how to implement that.
These are the methods..

def rewards_popup_description
  #return cta_description_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/," ")
  return cta_description_element.when_present(timeout = 
10).text.gsub(/[^$,.A-Za-z0-9]/," ")

end


def rewards_popup_expiration
  return cta_expiry_element.when_present(timeout = 
10).text.gsub(/[^$,.A-Za-z0-9]/," ")
end


Instead of this can I do something like, note :- in BOLD is PSEUDO CODE

cta_description_element.wait_while do
  cta_description_element.visible?   AND READ THE TEXT
end


cheers

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.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-08 Thread NaviHan
Hi Titus and Rajagopalan and Justin

The hook is written by another automation engineer, so Im yet to understand 
that fully.
Considering Im new to automation Im going through the learning curve and 
you guys are of immense help. 
Tomorrow I will be debugging the script in Jenkins box as to why reading 
the text from the popup fails just to remind this topic was started for 
that and in the midst we nailed the javascript issue. The confusion with 
wait_until and wait_while still bothers me.

Let me make it a bit more clearer to you.

1. The pop up appears and Im trying to assert two texts in that popup.
2. On local this passes but on Jenkins box the text is being read as empty

So Im thinking in the line, wait while the pop up disappears during that 
time read the texts in the pop up. I have this idea in mind but dont know 
how to implement that.
These are the methods..

def rewards_popup_description
  #return cta_description_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/," ")
  return cta_description_element.when_present(timeout = 
10).text.gsub(/[^$,.A-Za-z0-9]/," ")

end


def rewards_popup_expiration
  return cta_expiry_element.when_present(timeout = 
10).text.gsub(/[^$,.A-Za-z0-9]/," ")
end


Instead of this can I do something like

def rewards_popup_description
  #return cta_description_element.when_present.text.gsub(/[^$,.A-Za-z0-9]/," ")
  return cta_description_element.when_present(timeout = 
10).text.gsub(/[^$,.A-Za-z0-9]/," ")


end


def rewards_popup_expiration
  return cta_expiry_element.when_present(timeout = 
10).text.gsub(/[^$,.A-Za-z0-9]/," ")
end






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.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread NaviHan
s/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.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread NaviHan
Yes Justin, That was exactly what happened. I ran the script a few times 
and using "Watir::Wait.until(timeout: 30) {@browser.execute_script('return 
jQuery.active == 0')}" never gave me the error " 

Element ... *is not clickable* at 
point (537, 362). Other element would receive the click: *"


The code is

def select_online_size (size)
  Watir::Wait.until(timeout: 30) {@browser.execute_script('return jQuery.active 
== 0')}
  sizes_online_elements.find {|el| el.when_present.text.eql? size}.click
end

I was expecting that the "when_present" method would not give any timing 
issue because this waits until the element is present. Somehow this 
evaulates to true at the same time the spinner which is loading while the 
Ajax is running receives the click.


Is there a PO way to resolve this , I mean without having to use the 
"jQuery" statement


Cheers

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


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread NaviHan
Hi Titus

I found a good deal of documentation from PageObject wiki so was able to 
substitue the waits with PageObject equivalent.
https://github.com/cheezy/page-object/wiki/Ajax-Calls

Still the issue with spinner(Loader.bg) holds and Im working this around 
using "Watir::Wait.until(timeout: 30) {@browser.execute_script('return 
jQuery.active == 0')}"

Is there any solution in PageObject gem to handle this is still an open 
question. Do you reckon I could get some help somewhere?

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)

I dont get any idea out of this..



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


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread NaviHan
Yes Titus. I actually meant click after the wait. 

The stale element issue is resolved with Watir upgrade. 

I used jquery statement and managed to fix the issue. But what is the page 
object way to do that? 

Also could you please clarify the difference between wait.until(&:present?) and 
wait.while(&:present). I remember you mentioned the first wait for to be truthy 
and the latter tobefalsey. 

When I use both it gives the same results. I check the presence of an element 
using wait until present and if this evaluates to true do something.

wait while also does the same sometimes. 

Is there a good documentation on page object waits. It's really killing me. 

-- 
-- 
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: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-06 Thread NaviHan
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 https://ci.cottonon.com/AU/show-variation/?dwvar_2003013_color=2003013-05pid=2003013dwvar_2003013_size=XXSoriginalPid=2003013-05;
 title="Select Colour: BLACK" data-attribute-type="color">... is not 
clickable at point (504, 64). Other element would receive the click: 
 (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.

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: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-06 Thread NaviHan
ase.rb:27:in `block (2 levels) in describe_to'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/lib/cucumber/filters
/prepare_world.rb:22:in `block in test_case'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/around_hook.rb:17:in `execute'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/runner.rb:104:in `execute'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/runner.rb:51:in `execute'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/runner.rb:34:in `around_hook'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/around_hook.rb:12:in `describe_to'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/case.rb:120:in `block (2 levels) in compose_around_hooks'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/case.rb:121:in `compose_around_hooks'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/case.rb:26:in `block in describe_to'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/runner.rb:19:in `test_case'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/case.rb:25:in `describe_to'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/lib/cucumber/filters
/prepare_world.rb:11:in `test_case'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/case.rb:25:in `describe_to'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/filter.rb:57:in `test_case'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/lib/cucumber/filters
/retry.rb:18:in `test_case'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/case.rb:25:in `describe_to'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/lib/cucumber/filters
/quit.rb:12:in `test_case'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/case.rb:25:in `describe_to'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/lib/cucumber/filters
/broadcast_test_run_started_event.rb:21:in `block in done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/lib/cucumber/filters
/broadcast_test_run_started_event.rb:20:in `map'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/lib/cucumber/filters
/broadcast_test_run_started_event.rb:20:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/filter.rb:62:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/filter.rb:62:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/filter.rb:62:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/filter.rb:62:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/filter.rb:62:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/filters/locations_filter.rb:20:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/filter.rb:62:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/test/filters/tag_filter.rb:18:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/compiler.rb:24:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re/gherkin/parser.rb:37:in `done'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re.rb:32:in `parse'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.1.0/lib/cucumber/co
re.rb:21:in `compile'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/lib/cucumber/runtime
.rb:75:in `run!'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/lib/cucumber/cli/mai
n.rb:34:in `execute!'
  
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.1/bin/cucumber:9:in `<
top (required)>'
  C:/Ruby24-x64/bin/cucumber:23:in `load'
  C:/Ruby24-x64/bin/cucumber:23:in `'
  features/Store_Stock_Finder-AU.feature:155:in `And the user selects 
the co
lor "black"'


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

[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-06 Thread NaviHan
Still having issues with wait

  def select_variation_group(color)
variation_groups_elements.map do |element|
  element.wait_until { |el| el.title.include? color }
  element.click
end
  end

Error
Watir::Wait::TimeoutError: timed out after 10 seconds, waiting for true 
condition on #/Select Colour:/, 
:tag_name=>"a", :index=>0}>



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.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-06 Thread NaviHan
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 https://ci.cottonon.com/AU/show-variation/?dwvar_2003013_color=2003013-05pid=2003013dwvar_2003013_size=XXSoriginalPid=2003013-05;
 
title="Select Colour: BLACK" data-attribute-type="color">... is not 
clickable at point (504, 64). Other element would receive the click: 
  (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.

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: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-05 Thread NaviHan
Thanks Titus

Just wondering the difference between wait_until and wait_while. Do they 
bot do the same thing?

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.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-05 Thread NaviHan
Hi Titus

This actually works. Im yet to configure the script in Jenkins and verify 
because due to some reason the initial code worked sometimes on local but 
failed in Jenkis on all instances

@rewards_popup_txt = Watir::Wait.until{cta_description_element}.text"


Im eager to know what is the difference between "(&:present?)" and "(present)?"

Cheers


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.


[wtr-general] Re: Watir Website Updates

2018-08-04 Thread NaviHan
Great news Titus. I never knew about this blog.
Splendid content at first glance.

Will definitely give feedback once I have a detailed look.

Great to see experts like you contributing to the QA world. 


On Saturday, 4 August 2018 14:10:51 UTC+10, Titus Fortner wrote:
>
> I've been doing a good job of tweeting about new Watir blog posts (
> http://watir.com/blog/). If you don't already follow our Twitter account: 
> https://twitter.com/watir_team
>
> I've been doing a bad job of sending out messages on this mailing list 
> when I've made updates, I'll try to remember to do that.
>
> The biggest item of note is that we hired someone to fix up the design and 
> code of the website so that it is better organized and looks more 
> professional. This made it easier for me to finish what we started 2 years 
> ago and add in some content that was missing.
>
> I went through and updated all of the Guides (http://watir.com/guides/) 
> to delete obviously outdated material. I expounded on several of the topics 
> and added some code examples in places as well. The biggest improvement is 
> in the Locating Elements Guide (http://watir.com/guides/locating/). Check 
> it out, maybe you'll discover your new favorite locator that you didn't 
> know Watir supported.
>
> If you have any interest in helping add content or code examples to the 
> Guides, please feel free to contribute, the process is pretty 
> straightforward.
>
> I'd like to ask for feedback on two things. 
>
> First, the new website has not had comments associated with the blog 
> posts. Our chosen website technology (Jekyll) does not support it by 
> default. We have a few options to add on to it, and if you have an opinion 
> on the matter, please let us know. The discussion is here: 
> https://github.com/watir/watir.github.io/issues/4
>
> Also, I noticed we're still linking to the guidelines on the deprecated 
> watir_meta gem wiki. I'd like to move that to the website. I tried to 
> update the content to be more relevant and trim it down. Any feedback on 
> the sufficiency of this wording? 
> https://github.com/titusfortner/watir.github.io/blob/a38cbf9b/_pages/help.md#guidelines-for-questions-and-posts
>
> Thanks,
> Titus
>

-- 
-- 
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] Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-02 Thread NaviHan
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.


[wtr-general] Re: Trouble clicking a nested radio button under a unordered list and list item using PageObject

2018-07-25 Thread NaviHan
You are right Titus. I had a talk to the devs and found that the radio 
buttons are hidden lol.
So I just defined the labels as
labels(:in_store_sizes, :for => /instore_size/)

And then did the click and this worked, sigh..

But I havent progressed further, but I would like to ask one question
there is a label tag under each list element. Are they indexed so that I 
can access by index=0 etc?

Also wrt your previous reply I would like to ask you what was wrong with "
unordered_list(:sizes_instore, :class => /swatches instore/)" because you 
have suggested to modify it as  `class: ['swatches', 'instore']`

Thanks a lot for taking time to assist :-)
On Wednesday, 25 July 2018 13:51:06 UTC+10, NaviHan wrote:
>
> Banging my head over this.
> I have a section of page with a paren unordered list , list item and child 
> radio buttons
>
>  "true" data-disable-hover="true" tabindex="1" title="Please select a size"
> >
> 
> 
>  "dwfrm_stockinstoreavailability_sizeField" id="instore_size_XXS/XS" value=
> "XXS/XS" class="size-value">
>  "instore_size_XXS/XS" title="Select Size: XXS/XS" data-attribute-type=
> "size" data-size="XXS/XS" class="value-cont">
>  "swatchanchor-value">XXS/XS
> 
> 
> 
> 
>  "dwfrm_stockinstoreavailability_sizeField" id="instore_size_XS/S" value=
> "XS/S" class="size-value">
>  "instore_size_XS/S" title="Select Size: XS/S" data-attribute-type="size" 
> data-size="XS/S" class="value-cont">
>  "swatchanchor-value">XS/S
> 
> 
> 
> 
> 
> 
>
> I have defined the unordered list as 
>
> unordered_list(:sizes_instore, :class => /swatches instore/)
>
> Im trying to click the radio button under that using the following, none of 
> them worked
>
> sizes_instore_element.list_items[size_position.to_i].radio_button_element.select
> sizes_instore_element.list_items[size_position.to_i].radio_button_element.click
> sizes_instore_element.list_items[size_position.to_i].select_radio_button_element
>
> sizes_instore_element.list_items[size_position.to_i].radio.click
>
>
>
> Any clue?
>

-- 
-- 
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: Trouble clicking a nested radio button under a unordered list and list item using PageObject

2018-07-25 Thread NaviHan
Hi Titus

Tried that, but got readtimeout "Net::ReadTimeout: Net::ReadTimeout"
Looks like the element is not visible. I tried 
radio_set.select("XS") and also radio_set.radio(value: 'XXS/XS').label.click

radio_set = @browser.radio_set(class: 'size-value')
if (radio_set.radio(value: "XS").label.visible?)
  puts "visible"
else
  puts "Not Visible"
end


Thanks


On Wednesday, 25 July 2018 13:51:06 UTC+10, NaviHan wrote:
>
> Banging my head over this.
> I have a section of page with a paren unordered list , list item and child 
> radio buttons
>
>  "true" data-disable-hover="true" tabindex="1" title="Please select a size"
> >
> 
> 
>  "dwfrm_stockinstoreavailability_sizeField" id="instore_size_XXS/XS" value=
> "XXS/XS" class="size-value">
>  "instore_size_XXS/XS" title="Select Size: XXS/XS" data-attribute-type=
> "size" data-size="XXS/XS" class="value-cont">
>  "swatchanchor-value">XXS/XS
> 
> 
> 
> 
>  "dwfrm_stockinstoreavailability_sizeField" id="instore_size_XS/S" value=
> "XS/S" class="size-value">
>  "instore_size_XS/S" title="Select Size: XS/S" data-attribute-type="size" 
> data-size="XS/S" class="value-cont">
>  "swatchanchor-value">XS/S
> 
> 
> 
> 
> 
> 
>
> I have defined the unordered list as 
>
> unordered_list(:sizes_instore, :class => /swatches instore/)
>
> Im trying to click the radio button under that using the following, none of 
> them worked
>
> sizes_instore_element.list_items[size_position.to_i].radio_button_element.select
> sizes_instore_element.list_items[size_position.to_i].radio_button_element.click
> sizes_instore_element.list_items[size_position.to_i].select_radio_button_element
>
> sizes_instore_element.list_items[size_position.to_i].radio.click
>
>
>
> Any clue?
>

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


  1   2   >