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
saivik
Active particpant
Active particpant
Posts : 12
Join date : 2009-11-06

How to capture the alert message in Selenium IDE Empty 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
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

How to capture the alert message in Selenium IDE Empty 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
avatar
saivik
Active particpant
Active particpant
Posts : 12
Join date : 2009-11-06

How to capture the alert message in Selenium IDE Empty 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
avatar
saivik
Active particpant
Active particpant
Posts : 12
Join date : 2009-11-06

How to capture the alert message in Selenium IDE Empty 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?
avatar
tpskarthick
Posts : 6
Join date : 2010-02-09
Age : 38
Location : Chennai

How to capture the alert message in Selenium IDE Empty Re: How to capture the alert message in Selenium IDE

Tue Feb 09, 2010 3:20 pm
How to capture the alert message in Selenium IDE Icon_sad I too have the same problem in capturing the alert messages..... using selenium could any one help........
avatar
saivik
Active particpant
Active particpant
Posts : 12
Join date : 2009-11-06

How to capture the alert message in Selenium IDE Empty 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
avatar
tpskarthick
Posts : 6
Join date : 2010-02-09
Age : 38
Location : Chennai

How to capture the alert message in Selenium IDE Empty 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
avatar
tpskarthick
Posts : 6
Join date : 2010-02-09
Age : 38
Location : Chennai

How to capture the alert message in Selenium IDE Empty Re: How to capture the alert message in Selenium IDE

Tue Feb 09, 2010 5:11 pm


click
ctl00_ContentPlaceHolder1_btnSearch



storeAlertPresent




click
ctl00_ContentPlaceHolder1_btnSearch



storeAlertPresent




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.
avatar
sherin.jose
Posts : 1
Join date : 2011-08-19

How to capture the alert message in Selenium IDE Empty 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.
avatar
samson
Posts : 2
Join date : 2011-08-26

How to capture the alert message in Selenium IDE Empty 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
avatar
ejaenv
Posts : 5
Join date : 2011-08-26

How to capture the alert message in Selenium IDE Empty 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

avatar
samson
Posts : 2
Join date : 2011-08-26

How to capture the alert message in Selenium IDE Empty 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,
Sponsored content

How to capture the alert message in Selenium IDE Empty Re: How to capture the alert message in Selenium IDE

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