Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
umashankar
Active particpant
Active particpant
Posts : 24
Join date : 2011-11-14

Not able to click on "OK"   in  Alert box Empty Not able to click on "OK" in Alert box

Thu Nov 17, 2011 1:25 pm
Hi All,

I am new to selenium and now am trying Selenium IDE and stuck at " HOW TO CLICK ON "OK" IN ALERT BOX",

1. This step not recorded using selenium IDE.

2. I have tried using assertAlert, verifyAlert, ...etc but no luck.

3. In my application most of the scenarios has this Alert and need this to move forward.

4. Is there any way to overcome this issue?

Please anyone help me to fix this issue. Thanks a lot..



Thanks,

umashankar.v
avatar
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

Thu Nov 17, 2011 6:00 pm
Look at answerOnNextPrompt().
avatar
umashankar
Active particpant
Active particpant
Posts : 24
Join date : 2011-11-14

Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

Thu Nov 17, 2011 8:50 pm
Hi faramka,

Thanks for your info, I have tried using answerOnNextPrompt() and get result as,

  • [info] Executing: |click | //input[@id='ctl00_ContentPlaceHolder1_btnAdd'] | |

  • [info] Executing: |answerOnNextPrompt | You must enter a value in the following fields:- Upload jpg or pdf file only | |

  • [error] There was an unexpected Alert! [You must enter a value in the following fields: - Upload jpg or pdf file only]

  • Here while am running , i am not able to see that popup and i am getting the message as above.

    Can you please tell me what it exactly doing?

    Thanks
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Thu Nov 17, 2011 9:02 pm
    Did you use this method without any parameters?

    answerOnNextPrompt(answer)
    answer - the answer to give in response to the prompt pop-up


    Found at seleniumwiki
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 12:39 pm
    Hi Faramka,

    Thanks for your valuable info, Actually I want click "OK" when Alert pops up and want to perform other operations in the same page. Using answerOnNextPrompt its not clicking "OK" on the Alert and in the log its telling, "There was an unexpected Alert" as its not able to identify the Alert and Click on "OK", I am not able to perform any actions after that.

    Help me to overcome this issue. Thank you..
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 2:21 pm
    Try implement short delays between the actions by using one of the waitFor... methods and be sure the page is completely loaded.
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 2:51 pm
    Hi Faramka,

    I tried as you said but no luck, please check my code

    answerOnNextPrompt | |
    click | id=ct100_ContentPlaceHolder1_btnAdd |
    waitforAlertPresent
    type | id=ct100_ContentPlaceHolder1_txtCost |123

    I got the log as,

  • [info] Executing: |click | id=ctl00_ContentPlaceHolder1_btnAdd | |

  • [info] Executing: |waitForAlertPresent | | |

  • [info] Executing: |type | id=ctl00_ContentPlaceHolder1_txtCost | 123 |

  • [error] There was an unexpected Alert! [You must enter a value in the following fields: - Item ID - Description - Minimum Quantity - Maximum Qty - Category - Sub Category - Type - UOM ]

  • Here after click operation performed this Alert comes and i want to click on "OK" using selenium.

    Am trying by various way but no luck Faramka.

    Is there anyway to fix this issue??

    Help me guys....
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 3:42 pm
    As I told you earlier, the answerOnNextPrompt() takes a parameter. So you should do:
    answerOnNextPrompt|OK|
    or something like that.

    Let me know if you solved the problem.
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 3:53 pm
    Hi Faramka,

    Yes, i tried the way you said but no luck, now also getting the same error,

  • [info] Executing: |answerOnNextPrompt | OK | |

  • [info] Executing: |click | id=ctl00_ContentPlaceHolder1_btnAdd | |

  • [info] Executing: |type | id=ctl00_ContentPlaceHolder1_txtCost | 123 |

  • [error] There was an unexpected Alert! [You must enter a value in the following fields: - Item ID - Description - Minimum Quantity - Maximum Qty - Category - Sub Category - Type - UOM ]

  • Am not sure where i went wrong?

    Is there anyother way faramka???????
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 4:13 pm
    Maybe documentation could help....
    http://seleniumhq.org/docs/02_selenium_ide.html#alerts-popups-and-multiple-windows
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 4:28 pm
    Hi Faramka,

    Thank you so much for sharing this valuable info, I get to know that this feature is not available in Selenium, Check this


    getConfirmation()


    Returns:
    the message of the most recent JavaScript confirmation dialogRetrieves the message of a JavaScript confirmation dialog generated during the previous action.
    By default, the confirm function will return true, having the same effect as manually clicking OK. This can be changed by prior execution of the chooseCancelOnNextConfirmation command.

    If an confirmation is generated but you do not consume it with getConfirmation, the next Selenium action will fail.

    NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible dialog.

    NOTE: Selenium does NOT support JavaScript confirmations that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until you manually click OK.

    So unless we click manually it wont move to next step, Is it so?????



    Please share your idea..

    Thanks..
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 6:25 pm
    Is the alert similar to this one http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert ?
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 6:47 pm
    Hi faramka,

    Here i have attached the screen shot of it.. Please have a look at it and help me.

    Thanks.
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Fri Nov 18, 2011 9:21 pm
    OK, I've got your screenshot. Could you please right click on "OK" element of the alert and choose "inspect element" from the contextual menu, then show HTML from Firebug?
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 12:00 pm
    Hi Faramka,

    I tried as you said , but after alert pop-ups "RIGHT CLICK" is not working and i am not able to inspect the element. Only when i click on "OK" it is working, So its possible to click on "OK" faramka?
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 2:19 pm
    Hi Faramka,

    I tried with

    storeAlert | variablename |

    Its working fine, Thanks a lot faramka, but for some Alert when it pop-ups the page is in "Loading State" and still we clicking on "OK" its in loading state and in this case, i am not able to click on "OK". Also this Alert is visble when i run with "Selenium IDE". Faramka help me in this issue.
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 5:52 pm
    umashankar wrote:(...) but for some Alert when it pop-ups the page is in "Loading State" (...)
    Did you try wait until the page will load completely using waitForPageToLoad()?
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 6:23 pm
    Hi Faramka,

    I tried the way you said before but no luck and in the reference it given as,


    storeAlert(variableName)
    Generated from getAlert()


    Returns:
    The message of the most recent JavaScript alertRetrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
    Getting an alert has the same effect as manually clicking OK. If an alert is generated but you do not consume it with getAlert, the next Selenium action will fail.

    Under Selenium, JavaScript alerts will NOT pop up a visible alert dialog.

    Selenium does NOT support JavaScript alerts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.

    This alert is also "JavaScript alerts that are generated in a page's onload() event handler"

    How to handle this faramka?

    Thanks
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 6:34 pm
    Maybe this art would help:
    http://testerinyou.blogspot.com/2011/05/handling-alerts.html

    I'm sorry, but I have no more ideas. Maybe someone else would help you.
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 7:02 pm
    Hi Faramka,

    It was the same msg i posted above. Thank you so much for your great help..



    Many Thanks
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 7:22 pm
    So you solved the problem?
    I'm glad to managed to do it Smile
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 8:04 pm
    Hi Faramka,

    No, I didn't solved it. That says its not possible with Selenium IDE to click "OK" on Onload javascript Alert.

    So i thought it is not possible with Selenium IDE.

    If i was wrong please correct me.

    Thanks
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 8:29 pm
    In the first part of this article there is in fact the same error as you get, but further there is a solution of handling alerts. It is a
    script (java), but I think you can use some methods in Selenium IDE.
    Examine the code and try apply it in your work.
    Good luck Smile
    avatar
    umashankar
    Active particpant
    Active particpant
    Posts : 24
    Join date : 2011-11-14

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 8:45 pm
    Hi Faramka,

    You are correct but after i change the format to "Junit" the code is not get saved in "Selenium IDE". Hope this will work in "Selenium RC". But i know only Selenium IDE, Thought of work on "Selenium IDE" and after get confidence i will move on to "Selenium RC" and later version.

    Faramka, i have one doubt, is it possible in "Selenium IDE" to run the script after change the format to our desired language?

    If so, please help me in this..

    Thanks a lot..
    avatar
    faramka
    Professional
    Professional
    Posts : 143
    Join date : 2011-09-15
    Location : Poland

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Mon Nov 21, 2011 9:12 pm
    umashankar wrote:Faramka, i have one doubt, is it possible in "Selenium IDE" to run the script after change the format to our desired language?

    Unfortunately I don't know the answer to this question.

    umashankar wrote:Thought of work on "Selenium IDE" and after get confidence i will move on to "Selenium RC" and later version.

    In my opinion Selenium RC is more friendly and it has much more possibilities of simulation. Furthermore, writing scripts in it is not more difficult than execution of actions in IDE.
    Sponsored content

    Not able to click on "OK"   in  Alert box Empty Re: Not able to click on "OK" in Alert box

    Back to top
    Permissions in this forum:
    You cannot reply to topics in this forum