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.

[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