How to handle confirmation boxes...

168 views
Skip to first unread message

NagaRaju dasam

unread,
Oct 28, 2011, 8:56:31 AM10/28/11
to Selenium Users, webd...@googlegroups.com
Hi All,

I am working on web driver. I am unable to Handle confirmation box. 

Scenario:

When i click a button it opens a confirmation box wiht two buttons (OK and Cancel).

I used...driver.switchto().alert().accept() and Dismiss().

But the above command is not working. I tried Java script also but no use...

Java script is 

((JavaScriptExecutor)Driver).ExecuteScript("window.confirm =function(msg){return true;};"); 

Please suggest me any other method...Thanks in advance.

--
Thanks,
Naga

Simon Stewart

unread,
Oct 31, 2011, 5:35:13 AM10/31/11
to Selenium Users
You don't mention which browser you're using, or which version of
Selenium either. Having said that, the "accept" or "dismiss" methods
should work as expected.

Simon

> --
> You received this message because you are subscribed to the Google Groups
> "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to
> webdriver+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/webdriver?hl=en.
>

NagaRaju dasam

unread,
Oct 31, 2011, 6:22:37 AM10/31/11
to seleniu...@googlegroups.com
Hi Simon,

I am using IE 8 and  selenium 2.6.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Simon Stewart

unread,
Oct 31, 2011, 8:23:31 AM10/31/11
to seleniu...@googlegroups.com
Could you please try Selenium 2.11? I know that we've put in a lot of
work since 2.6 :)

Simon

NagaRaju dasam

unread,
Oct 31, 2011, 9:00:24 AM10/31/11
to seleniu...@googlegroups.com
Thanks Simon i will try with latest version..

And one more question...

I am working on multiple windows


Scenarios is 
1. Click a link and it will open a new window.
2. i am able to shift focus to child window/new window
3. I performed some actions on new window and clicked save button..the new window is anutoamtically closed.

Now the problem is Selenium control is missing it is not automatically shift to parent/Main window.

i used driver.switchto().defaultcontent();

but focus is not coming to main winodow. i used window handlers also...but no use..is there any way to shift control to main window..??
Because of this issue i struck...is there any alternative for this? Some one told that it is selenium issue..Do you have any idea about it? Thanks in advance.

Jim Evans

unread,
Oct 31, 2011, 9:34:25 AM10/31/11
to Selenium Users
You should save the current window handle to a variable before
clicking the link that opens the new window. Then you can switch back
to it after you close the window. You can do this with
the .getWindowHandle() method on your WebDriver object[1].

--Jim

[1] This is true for Java; different languages will have slightly
different syntax. C#, for example would be using
the .CurrentWindowHandle property on your IWebDriver object.


On Oct 31, 9:00 am, NagaRaju dasam <nagaselen...@gmail.com> wrote:
> Thanks Simon i will try with latest version..
>
> And one more question...
>
> I am working on multiple windows
>
> Scenarios is
> 1. Click a link and it will open a new window.
> 2. i am able to shift focus to child window/new window
> 3. I performed some actions on new window and clicked save button..the new
> window is anutoamtically closed.
>
> Now the problem is Selenium control is missing it is not automatically
> shift to parent/Main window.
>
> i used driver.switchto().defaultcontent();
>
> but focus is not coming to main winodow. i used window handlers also...but
> no use..is there any way to shift control to main window..??
> Because of this issue i struck...is there any alternative for this? Some
> one told that it is selenium issue..Do you have any idea about it? Thanks
> in advance.
>
> On Mon, Oct 31, 2011 at 8:23 AM, Simon Stewart <simon.m.stew...@gmail.com>wrote:
>
>
>
>
>
> > Could you please try Selenium 2.11? I know that we've put in a lot of
> > work since 2.6 :)
>
> > Simon
>
> > On Mon, Oct 31, 2011 at 10:22 AM, NagaRaju dasam <nagaselen...@gmail.com>
> > wrote:
> > > Hi Simon,
> > > I am using IE 8 and  selenium 2.6.
>
> > > On Mon, Oct 31, 2011 at 5:35 AM, Simon Stewart <
> > simon.m.stew...@gmail.com>
> > > wrote:
>
> > >> You don't mention which browser you're using, or which version of
> > >> Selenium either. Having said that, the "accept" or "dismiss" methods
> > >> should work as expected.
>
> > >> Simon
>
> > >> On Fri, Oct 28, 2011 at 5:56 AM, NagaRaju dasam <nagaselen...@gmail.com
> Nagahttp://testerinyou.blogspot.com/- Hide quoted text -
>
> - Show quoted text -

NagaRaju dasam

unread,
Oct 31, 2011, 11:03:57 AM10/31/11
to seleniu...@googlegroups.com
Hi Jim,

The problem is automatically closed windows..1.if the new window closed automatically after clickin save button on new window then i am unable to shift webdriver focus to main window.2. if the child window is not closed and if i close it using driver.close() then i am able to shift focus to main window...


The problem occurs in first case...

Hope you understood my problem..

Shilpa

unread,
Jul 6, 2015, 2:35:22 AM7/6/15
to seleniu...@googlegroups.com, nagase...@gmail.com
Hello All,
Can anyone pls tell me  how switch from alert to new window.
Basically scenario is -
1. search record .
2.Click on record - new popup window is opened
3.all the details of record is displayed in that popup.
4.Edit some fields and Click on Save button.
5.One small pop up is displayed , in that enter name and click on save button .
6.Confirmation alert is displayed and after accepting the alert new window is opened.



So i m facing problem after accepting alert couldn't switch to new window .


Panikera Raj

unread,
Jul 6, 2015, 3:04:01 AM7/6/15
to selenium-users, nagase...@gmail.com
Hi Shilpa,

the new window is Native window or web browser window?. Can we have screen shot for the same.

if it is web browser window you can use method as :

driver.getwindowhandles();

if it is native window then try with autoIT or Sikuli tools.


Regards,
Panikera


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages