The issue is that sometimes an alert has popped up. Whenever an alert is 
present, the driver will not accept any commands that do not deal with that 
alert. Just like a user can't do anything on a site without dismissing it. 
That includes screenshots. Rescuing the error won't help if you just send 
another non-alert handling command.

These appear to be "real" errors as in the site appears to be responding 
improperly and your tests are finding an actual issue.

As the developer what would cause a JS alert of `Bad response - parser 
error!` or `Couldn't load credit card! ` since these Strings are somewhere 
in your app code. Also log the wire calls getting sent to the driver to see 
exactly what is causing the alert (`Selenium::WebDriver.logger.level = 
:info`)


As a side note, Watir is lazy loaded, so this code won't actually do 
anything.
Watir::Wait.until {element}

`element` object instance will immediately return a truthy value and no 
waiting happens.

It shouldn't matter, though, because `#focus` will automatically wait for 
the element to exist and `#click` will automatically wait for the element 
to be displayed.




On Tuesday, December 4, 2018 at 7:31:56 PM UTC-7, 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 <top (required)>' 
>
> ./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.

[email protected]
http://groups.google.com/group/watir-general
[email protected]
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to