Hi,

I did the following changes but then also not bale to click on the OK
button.
Please suggest if I am wrong.
IE version I was using is 6.So I did the following steps-
1> changed the title on the JS Alert box in WinClicker.rb file
    IE6 = "Microsoft Internet Explorer"

2> Made changes to the script

require 'watir'
include Watir

def check_for_popups(title="Microsoft Internet Explorer", button="OK")
    popup=Thread.new {
        autoit=WIN32OLE.new('AutoItX3.Control')
        ret=autoit.WinWait(title,"",60)
        if (ret==1)
            puts "There is popup."
            autoit.WinActivate(title)
            button.downcase!
            if button.eql?("ok") || button.eql?("yes") || button.eql?
("continue")
                autoit.Send("{Enter}")
            else
                autoit.Send("{tab}")
                autoit.Send("{Enter}")
            end
        elsif (ret==0)
            puts "No popup"
        end
    }
    at_exit { Thread.kill(popup) }
end

$ie = Watir::IE.new
$ie.goto("http://localhost/new";)
$ie.text_field(:name, "userName").set("user1")
$ie.text_field(:name, "password").set("password")
$ie.button(:value, "Login").click
$ie.link(:text, "Manage Products").click
$ie.link(:text, "Create Product").click
$ie.text_field(:name, "productName").set('Test')
$ie.text_field(:name, "description").set('Test1')
$ie.button(:name, "submit_btn").click
check_for_popups("Microsoft Internet Explorer", "OK")


Thanks
Maumita

On Jun 23, 9:14 pm, orde <ohil...@gmail.com> wrote:
> Check these pages out:
>
> http://wiki.openqa.org/display/WTR/Pop+Upshttp://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups
>
> orde
>
> On Jun 23, 5:24 am, Maumita <maumita.majum...@gmail.com> wrote:
>
> > Hi,
>
> > I am facing a problem.
> > I had written a script that submit a form.Befor submitting the form,if
> > any field entry is missing in the form then a java pop-up window
> > appears.
> > Windows title -Microsoft Internet Explorer
> > Prompt Message - 'You have not selected an image.Do you want to
> > continue'.
> > This window has Ok and cancel button.
> > when user clicks on Ok the form automatically gets submitted.
>
> > I don't know how to click on the OK button when the pop up window
> > appears.
>
> > Please suggest me.
>
> > Below is my script -
>
> > require 'watir'
> > require 'win32ole'
> > include Watir
>
> >     $excel_path = "D:/Data/dportalTestScripts/Product.xlsx"
> >     $sheet_id   = 1
> >     $excel = WIN32OLE.new("excel.application")
> >     $excel['Visible'] = true;
> >     $workbook = $excel.Workbooks.Open $excel_path
> >     $worksheet = $workbook.WorkSheets($sheet_id)
> >     $worksheet.Select
>
> > ie = Watir::IE.new
>
> > #Navigate to dportal
> > ie.goto("http://test/new";)
> > ie.text_field(:name, "userName").set("")
> > ie.text_field(:name, "password").set("")
> > ie.button(:value, "Login").click
> > ie.link(:text, "Manage Products").click
> > ie.link(:text, "Create Product").click
>
> >       ie.text_field(:name, "productName").set $worksheet.Range("a#
> > {i}").value
> >       ie.text_field(:name, "description").set $worksheet.Range("b#
> > {i}").value
> >       ie.text_field(:name, "copyright").set $worksheet.Range("c#
> > {i}").value
> >       ie.text_field(:name, 'releaseDate').value= $worksheet.Range("d#
> > {i}").value
> >       #ie.fileField(:name, "imageFile").set $worksheet.Range("f#
> > {i}").value
> >       ie.select_list(:name, "vendor").select $worksheet.Range("e#
> > {i}").value
> >       ie.select_list(:name, "instrument").select $worksheet.Range("f#
> > {i}").value
> >       ie.select_list(:name, "cds").select $worksheet.Range("g#
> > {i}").value
> >       ie.checkbox(:name, "isPublished").set
> >       ie.text_field(:name, "productCosts[0].cost").value=
> > $worksheet.Range("h#{i}").value
> >       ie.button(:name, "submit_btn").click_no_wait
>
> >  Thanks
> > Maumita
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to