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
gchandrasekaran82
Regular Participant
Regular Participant
Posts : 33
Join date : 2011-02-16

How to use If statement? Empty 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,
avatar
Yure_ts
Posts : 2
Join date : 2011-02-22

How to use If statement? Empty 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
avatar
Priyanka
Regular Participant
Regular Participant
Posts : 27
Join date : 2010-10-04

How to use If statement? Empty Re: How to use If statement?

Fri Mar 04, 2011 12:23 pm
Thanks for sharing
rohit13
rohit13
Master
Master
Posts : 180
Join date : 2012-03-29
Age : 38
Location : INDIA
http://radical-qa.blogspot.in/

How to use If statement? Empty 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...
avatar
rashmichauhan
Posts : 3
Join date : 2012-10-03

How to use If statement? Empty 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 :



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
avatar
Qasubzero
Posts : 1
Join date : 2013-10-07

How to use If statement? Empty 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.
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

How to use If statement? Empty Re: How to use If statement?

Mon Oct 07, 2013 9:36 pm
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.
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.
kashyap_guru
kashyap_guru
Active particpant
Active particpant
Posts : 24
Join date : 2013-10-16
Age : 37
Location : India

How to use If statement? Empty 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??
Sponsored content

How to use If statement? Empty Re: How to use If statement?

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