Titus,

I tried but it both reports the following error.

If I use ,

b.alert.ok

then I am having the following error

Uncaught exception: undefined method `alert' for 
#<Watir::HTMLElement:0x2050068>
 
C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.5.0/lib/watir/elements/element.rb:693:in
 
`method_missing'
 
C:/Users/rajagopalan.m/RubymineProjects/SeleniumLearning/Contact/ModuleExample.rb:140:in
 
`<top (required)>'

If I use 

iframe.b.alert.ok

then I have the following error,

Uncaught exception: unable to locate alert
 C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.5.0/lib/watir/alert.rb:115:in 
`rescue 
in wait_for_exists'
 C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.5.0/lib/watir/alert.rb:106:in `
wait_for_exists'
 C:/Ruby23/lib/ruby/gems/2.3.0/gems/watir-6.5.0/lib/watir/alert.rb:36:in 
`ok'
 C:/Users/rajagopalan.m/RubymineProjects/SeleniumLearning/Contact/
ModuleExample.rb:140:in `<top (required)>'





On Tuesday, August 1, 2017 at 10:03:00 AM UTC+5:30, Titus Fortner wrote:
>
> Yes, you need to use `browser.alert.ok` directly
>
> If you really need to do it in the context of iframe, you can do 
> `iframe.browser.alert.ok` (so long as iframe has already been located)
>
> Selenium won't let you send any wire call that isn't related to an alert 
> if an alert is displayed.
>
>
>
> On Monday, July 31, 2017 at 11:19:19 PM UTC-5, Raja gopalan wrote:
>>
>> Okay, this actually resolves the problem, Yes as you say, it's inside the 
>> frame and when I use as shown below
>>
>> iframe1 = browser.iframe(id: 'iframe1')
>> iframe1.element(id: 'element_inside_frame').click
>>
>> it works, But another problem arises in the case of alert, I don't know 
>> how to handle alert now. 
>>
>> If I write 
>>
>> iframe1.alert.ok 
>>
>> It simply throws the error by saying 'alert' function is not found for 
>> iframe1. Can you tell me how to handle the alert when alert appears inside 
>> the frame? 
>>
>> On Friday, July 28, 2017 at 11:58:10 PM UTC+5:30, Titus Fortner wrote:
>>>
>>> Working with iframes is approached differently in selenium & Watir.
>>> In Selenium you are responsible for explicitly switching into and out of 
>>> the context you want:
>>>
>>> driver.switch_to.frame('iframe1')
>>> driver.find_element(id: 'element_inside_frame').click
>>> driver.switch_to.default_content
>>> driver.find_element(id: 'element_outside_frame').click
>>>
>>> Watir handles this for you:
>>>
>>> browser.iframe(id: 'iframe1').element(id: 'element_inside_frame').click
>>> browser.element(id: 'element_outside_frame').click
>>>
>>> The tradeoff for this behavior is that you have to include the iframe 
>>> definition as part of every element signature inside the iframe.
>>> For convenience, feel free to:
>>>
>>> iframe1 = browser.iframe(id: 'iframe1')
>>> iframe1.element(id: 'element_inside_frame').click
>>> iframe1.element(id: 'also_inside_frame').click
>>>
>>>
>>> You could have elements with the same id in multiple different 
>>> frames/browsing contexts. Watir requires you to explicitly specify which 
>>> one you want. 
>>>
>>>
>>> On Fri, Jul 28, 2017 at 12:42 PM, Raja gopalan <rajagopa...@gmail.com> 
>>> wrote:
>>>
>>>> But why this difficulty while I use in WATIR? Selenium is allowing me 
>>>> to access without any these kind of trouble. WATIR should eases that the 
>>>> selenium coding, but here it makes it difficult. 
>>>>
>>>>
>>>> On Friday, July 28, 2017 at 8:20:51 PM UTC+5:30, Titus Fortner wrote:
>>>>>
>>>>> Watir should now only send the null value to the frame endpoint if the 
>>>>> element in question is inside an iframe. So this could make sense. You 
>>>>> need 
>>>>> to include the iframe definition as a parent object whenever defining 
>>>>> elements inside of it.
>>>>
>>>> -- 
>>>> -- 
>>>> Before posting, please read http://watir.com/support. In short: search 
>>>> before you ask, be nice.
>>>>  
>>>> watir-...@googlegroups.com
>>>> http://groups.google.com/group/watir-general
>>>> watir-genera...@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-genera...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>

-- 
-- 
Before posting, please read http://watir.com/support. 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.

Reply via email to