How to use If statement?
+4
rohit13
Priyanka
Yure_ts
gchandrasekaran82
8 posters
- gchandrasekaran82Regular Participant
- Posts : 33
Join date : 2011-02-16
How to use If statement?
Sun Feb 20, 2011 1:36 am
Hi Please help me how to do this condition:
I need to do the below condition
gotoIf -->If the Page is A--> Target1
gotoIf -->If the page is B--> Target2
Just let me know how to check if the page is A then one set of code need to be executed if it is others then the other set...
Thanks
Chandrasekaran G,
I need to do the below condition
gotoIf -->If the Page is A--> Target1
gotoIf -->If the page is B--> Target2
Just let me know how to check if the page is A then one set of code need to be executed if it is others then the other set...
Thanks
Chandrasekaran G,
- Yure_ts
- Posts : 2
Join date : 2011-02-22
Re: How to use If statement?
Tue Feb 22, 2011 4:31 pm
Hi, you need extension which allows branching.
Nice description is presented here http://www.computerminds.co.uk/automating-boring-tasks-selenium-ide
Nice description is presented here http://www.computerminds.co.uk/automating-boring-tasks-selenium-ide
- PriyankaRegular Participant
- Posts : 27
Join date : 2010-10-04
Re: How to use If statement?
Fri Mar 04, 2011 12:23 pm
Thanks for sharing
Re: How to use If statement?
Sat Mar 31, 2012 1:54 pm
- Code:
open | URL of site
storeTextPresent | any unique text of page a | title
gotoIf | storedVars.title | true
getEval | alert("page B");
gotolabel | finish
label | true
getEval | alert("Page A");
label | finish
This is sample code with use of gotoif.
It will check whether title is present or not, if present control will redirect to label true, else will execute next statement after gotoif.
Let me know if any more help requires...
- rashmichauhan
- Posts : 3
Join date : 2012-10-03
Re: How to use If statement?
Thu Oct 11, 2012 1:10 pm
I am using Selenium IDE for testing my application.
I have sufficient plug in and I am also getting If else option in
command drop down in Selenium IDE. Can you please suggest me how to
insert If Else condition in recorded script.
The Scenario is that there are 5 rights Campaign Administrator, User Management, Customer Management, Personal, Reports.
Some users have Campaign Administrator right, Some User have User Management right, Some are Customer Management right.
The
page display in each type area is different i. e. The page display in
Campaign Management is not visible to the user who have right of User
Management.
After recording script when I playback the same script for other user the script goes fail because the page is not found.
I
want to handle this situation with If Else condition if the page is not
found then the script skip the section and on place of giving error
it's pass.
The code is following :
Regards
Rashmi Chauhan
rashmi@banyantreesoft.com
I have sufficient plug in and I am also getting If else option in
command drop down in Selenium IDE. Can you please suggest me how to
insert If Else condition in recorded script.
The Scenario is that there are 5 rights Campaign Administrator, User Management, Customer Management, Personal, Reports.
Some users have Campaign Administrator right, Some User have User Management right, Some are Customer Management right.
The
page display in each type area is different i. e. The page display in
Campaign Management is not visible to the user who have right of User
Management.
After recording script when I playback the same script for other user the script goes fail because the page is not found.
I
want to handle this situation with If Else condition if the page is not
found then the script skip the section and on place of giving error
it's pass.
The code is following :
- Code:
open /Login.aspx
type id=LoginCtrl_UserName chetanmistry
type id=LoginCtrl_Password chetanmistry
clickAndWait id=LoginCtrl_LoginButton
clickAndWait link=Reporting
clickAndWait link=Campaign Management
clickAndWait link=Customer Management
clickAndWait link=User Management
clickAndWait link=System Administration
clickAndWait link=Personal
clickAndWait id=ctl00_loginStatus
Regards
Rashmi Chauhan
rashmi@banyantreesoft.com
- Qasubzero
- Posts : 1
Join date : 2013-10-07
Re: How to use If statement?
Mon Oct 07, 2013 2:41 pm
Hi,
Is it possible to go to particular command using gotoif?
I want to check if the checkboxes/Radio buttons are selected. If they are NOT checked then I want to check and if they are checked I want to uncheck them using gotoif.
Could you please help me in doing that?
Thanks in advance.
Is it possible to go to particular command using gotoif?
I want to check if the checkboxes/Radio buttons are selected. If they are NOT checked then I want to check and if they are checked I want to uncheck them using gotoif.
Could you please help me in doing that?
Thanks in advance.
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO
Re: How to use If statement?
Mon Oct 07, 2013 9:36 pm
That is the intended use of gotoIf. What you described is very possible. First use the 'storeChecked' command on those checkboxes. Then go to the label for one path to click on the boxes if they are not checked and another label to unselect them if they are checked.Qasubzero wrote:Hi,
Is it possible to go to particular command using gotoif?
I want to check if the checkboxes/Radio buttons are selected. If they are NOT checked then I want to check and if they are checked I want to uncheck them using gotoif.
Could you please help me in doing that?
Thanks in advance.
- kashyap_guruActive particpant
- Posts : 24
Join date : 2013-10-16
Age : 37
Location : India
Re: How to use If statement?
Wed Oct 16, 2013 7:21 pm
Hi Rashmi,
In your case, you would have only one link at a time. Right?
Like, if chetan mistry is logged in, and that user is having rights of USER MANAGEMENT, then there would be only one link as "User Management".
Then you just need to store that element's text and compare it.
open /Login.aspx
type id=LoginCtrl_UserName chetanmistry
type id=LoginCtrl_Password chetanmistry
clickAndWait id=LoginCtrl_LoginButton
clickAndWait link=User Management
gotoif storedtext=="User Management" usermanagement
gotoif storedtext=="Campain Management" campainmanagement
gotoif storedtext=="Customer Management" customermanagement
label usermanagement
Open usermanagement.aspx
goto laststep
label campainmanagement
open campainmanagement.aspx
goto laststep
label customermanagement
open customermanagement.aspx
goto laststep
label laststep
echo Process Completed
understood??
In your case, you would have only one link at a time. Right?
Like, if chetan mistry is logged in, and that user is having rights of USER MANAGEMENT, then there would be only one link as "User Management".
Then you just need to store that element's text and compare it.
open /Login.aspx
type id=LoginCtrl_UserName chetanmistry
type id=LoginCtrl_Password chetanmistry
clickAndWait id=LoginCtrl_LoginButton
clickAndWait link=User Management
gotoif storedtext=="User Management" usermanagement
gotoif storedtext=="Campain Management" campainmanagement
gotoif storedtext=="Customer Management" customermanagement
label usermanagement
Open usermanagement.aspx
goto laststep
label campainmanagement
open campainmanagement.aspx
goto laststep
label customermanagement
open customermanagement.aspx
goto laststep
label laststep
echo Process Completed
understood??
Permissions in this forum:
You cannot reply to topics in this forum