- saivikActive particpant
- Posts : 12
Join date : 2009-11-06
How to capture the alert message in Selenium IDE
Fri Nov 06, 2009 5:29 pm
I am stuck with capturing the alert message.
The Scenario is:
I have a form with input fields like CaseType(listbox), Lab(listbox), LastName(txtbox), FirstName(txtbox)... along with couple of other fields as well.
After entering all the fields, i click on Proceed button to submit the form.
When i click on Proceed button, an alert triggers with a message saying
"Case successfully submitted with Number: SLPS2009-123456". with an OK button.
So, now I have to verify that the alert has triggered and also i have to capture the entire message for using in the next pages.
I am really stuck with verifying and capturing the message through Selenium IDE.
I tried by using getAlert, assertAlert, assertAlertPresent.
But none of the things worked for me.
Can anyone pls put some light on my query....??? would really appreciate ur kind help.
-Saivik
The Scenario is:
I have a form with input fields like CaseType(listbox), Lab(listbox), LastName(txtbox), FirstName(txtbox)... along with couple of other fields as well.
After entering all the fields, i click on Proceed button to submit the form.
When i click on Proceed button, an alert triggers with a message saying
"Case successfully submitted with Number: SLPS2009-123456". with an OK button.
So, now I have to verify that the alert has triggered and also i have to capture the entire message for using in the next pages.
I am really stuck with verifying and capturing the message through Selenium IDE.
I tried by using getAlert, assertAlert, assertAlertPresent.
But none of the things worked for me.
Can anyone pls put some light on my query....??? would really appreciate ur kind help.
-Saivik
Re: How to capture the alert message in Selenium IDE
Sat Nov 07, 2009 4:06 pm
hi,
First of all welcome to this forum and thanks to post your query. Now lets move to your query.
1. to get the text of your alert box, use any of the following commands:
storeAlert | variableName |
storeConfirmation | variableName |
then use the value like : $variableName. This command will also click on OK button automatically.
2. to verify your alert use this:
storeAlertPresent(variableName)
3. There is one more command present, If you want to click on cancel button instead of OK button:
chooseCancelOnNextConfirmation()
To get information related to all functions avaliable in selenium, check out this link:
http://release.seleniumhq.org/selenium-core/0.8.0/reference.html
Best of luck.
Bye
First of all welcome to this forum and thanks to post your query. Now lets move to your query.
1. to get the text of your alert box, use any of the following commands:
storeAlert | variableName |
storeConfirmation | variableName |
then use the value like : $variableName. This command will also click on OK button automatically.
2. to verify your alert use this:
storeAlertPresent(variableName)
3. There is one more command present, If you want to click on cancel button instead of OK button:
chooseCancelOnNextConfirmation()
To get information related to all functions avaliable in selenium, check out this link:
http://release.seleniumhq.org/selenium-core/0.8.0/reference.html
Best of luck.
Bye
- saivikActive particpant
- Posts : 12
Join date : 2009-11-06
Re: How to capture the alert message in Selenium IDE
Tue Nov 24, 2009 2:13 am
Hi,
I am trying like this,
[tr]< tr >
[td]< td >clickAndWait[/td]
[td]btnSubmit
[/td]
[td][/td]
[/tr]
[tr]
[td]storeAlert[/td]
[td][/td]
[td]var1[/td]
[/tr]
[tr]
[td]echo[/td]
[td]${var1}[/td]
[td][/td]
[/tr]
But no success. It shows the msg "There are no Alerts".
Even i tried with storeConfirmation also...but not getting.
Could u pls give me any sample working script, that captures the alert message?
I would be really thankful to you. Pls Kindly help me.
-Saivik
I am trying like this,
[tr]< tr >
[td]< td >clickAndWait[/td]
[td]btnSubmit
[/td]
[td][/td]
[/tr]
[tr]
[td]storeAlert[/td]
[td][/td]
[td]var1[/td]
[/tr]
[tr]
[td]echo[/td]
[td]${var1}[/td]
[td][/td]
[/tr]
But no success. It shows the msg "There are no Alerts".
Even i tried with storeConfirmation also...but not getting.
Could u pls give me any sample working script, that captures the alert message?
I would be really thankful to you. Pls Kindly help me.
-Saivik
- saivikActive particpant
- Posts : 12
Join date : 2009-11-06
Re: How to capture the alert message in Selenium IDE
Tue Nov 24, 2009 1:36 pm
I recorded a script with alerts. the Selenium IDE save the command assertAlert with the message of that alert in target.
When I play this script this command fails and the button OK isn't pressed!
How to do this? Pls provide me some workaround.
How I can replace assertAlert with another command that works?
When I play this script this command fails and the button OK isn't pressed!
How to do this? Pls provide me some workaround.
How I can replace assertAlert with another command that works?
- tpskarthick
- Posts : 6
Join date : 2010-02-09
Age : 38
Location : Chennai
Re: How to capture the alert message in Selenium IDE
Tue Feb 09, 2010 3:20 pm
I too have the same problem in capturing the alert messages..... using selenium could any one help........
- saivikActive particpant
- Posts : 12
Join date : 2009-11-06
Re: How to capture the alert message in Selenium IDE
Tue Feb 09, 2010 3:35 pm
@tpskarthick,
I am looking for a work around on that issue. If i get to know, will update you.
-Saivik
I am looking for a work around on that issue. If i get to know, will update you.
-Saivik
- tpskarthick
- Posts : 6
Join date : 2010-02-09
Age : 38
Location : Chennai
Re: How to capture the alert message in Selenium IDE
Tue Feb 09, 2010 4:55 pm
Hey ,,,,,,,,,
I got that fixed savik what adviser said is right use "storeAlertPresent" which identifies the alert messages,,,,,,,,,,,,,, try it dude
I got that fixed savik what adviser said is right use "storeAlertPresent" which identifies the alert messages,,,,,,,,,,,,,, try it dude
- tpskarthick
- Posts : 6
Join date : 2010-02-09
Age : 38
Location : Chennai
Re: How to capture the alert message in Selenium IDE
Tue Feb 09, 2010 5:11 pm
On clicking the search button an alert is displayed but it is not identified by selenium IDE kindly give me a solution. but al the alerts are accepted by using the storeassertvalue.
- sherin.jose
- Posts : 1
Join date : 2011-08-19
Re: How to capture the alert message in Selenium IDE
Fri Aug 19, 2011 4:21 pm
I am stuck with capturing the alert message.i am entering wrong password.and after login there is one alert like "Error Details : Invalid Password".i am using following code.
selenium.open("");
selenium.type("txtUserID", "sreejit");
selenium.type("txtPassword", "xyz");
selenium.waitForPageToLoad("30000")
selenium.click("btnLogin");
System.out.println("Alert1 " + selenium.getAlert());
but i getting error message like "There were no alerts".but im sure one alert is coming.Pls Kindly help me.
selenium.open("");
selenium.type("txtUserID", "sreejit");
selenium.type("txtPassword", "xyz");
selenium.waitForPageToLoad("30000")
selenium.click("btnLogin");
System.out.println("Alert1 " + selenium.getAlert());
but i getting error message like "There were no alerts".but im sure one alert is coming.Pls Kindly help me.
- samson
- Posts : 2
Join date : 2011-08-26
Re: How to capture the alert message in Selenium IDE
Mon Aug 29, 2011 1:09 pm
Hi Adviser, Can i have the sample script for the above solution which you gave.
i Accept the Answer of yours, as there will be a alert to the sys after a event, .....
waiting for your answer..
Thank you,
Samson. B
i Accept the Answer of yours, as there will be a alert to the sys after a event, .....
waiting for your answer..
Thank you,
Samson. B
- ejaenv
- Posts : 5
Join date : 2011-08-26
Re: How to capture the alert message in Selenium IDE
Mon Aug 29, 2011 3:06 pm
Selenium's IDE browserbot captures alerts. AFAIK The reason why alerts are not captured is because the browserbot isn't set until the onLoad() event has occurred, so any alerts that occur before this event aren't captured and then the popup appears.
So the solution is to be sure that browserbot is set before the alert occurs. Googling I found 2 solutions:
option 1) set a timeout - the one which I use and it works
SO:
alert(..)
PUT:
function delayAlert() {
alert(...);
}
window.setTimeout("delayAlert()",1000)
option 2) put this capturing code before the alert:
var browserbot = parent.selenium.browserbot;
if (browserbot) {
browserbot.modifyWindowToRecordPopUpDialogs(window, browserbot);
}
alert("Alert message after those selenium workaround js snippet");
BTW the IDE commands I use are:
waitForAlertPresent |
storeAlert | alerta
echo | ${alerta}
OR
waitForAlertPresent |
assertAlert | "your alert message"
hope it helps
So the solution is to be sure that browserbot is set before the alert occurs. Googling I found 2 solutions:
option 1) set a timeout - the one which I use and it works
SO:
alert(..)
PUT:
function delayAlert() {
alert(...);
}
window.setTimeout("delayAlert()",1000)
option 2) put this capturing code before the alert:
var browserbot = parent.selenium.browserbot;
if (browserbot) {
browserbot.modifyWindowToRecordPopUpDialogs(window, browserbot);
}
alert("Alert message after those selenium workaround js snippet");
BTW the IDE commands I use are:
waitForAlertPresent |
storeAlert | alerta
echo | ${alerta}
OR
waitForAlertPresent |
assertAlert | "your alert message"
hope it helps
- samson
- Posts : 2
Join date : 2011-08-26
Re: How to capture the alert message in Selenium IDE
Mon Aug 29, 2011 6:39 pm
Here i'm placing the sample[solution] for above questions...
For example when logout has a confirmation :
you may follow in this sequence :
selenium.chooseCancelOnNextConfirmation();
selenium.click("link=Logout");
String are = selenium.getConfirmation();
System.out.println(are);
I hope the above will be understood by the who r working on selenium rc.using junit3.
Thank you,
For example when logout has a confirmation :
you may follow in this sequence :
selenium.chooseCancelOnNextConfirmation();
selenium.click("link=Logout");
String are = selenium.getConfirmation();
System.out.println(are);
I hope the above will be understood by the who r working on selenium rc.using junit3.
Thank you,
Permissions in this forum:
You cannot reply to topics in this forum