Search
 
 

Display results as :
 


Rechercher Advanced Search

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

How to use If statement?

View previous topic View next topic Go down

How to use If statement?

Post by gchandrasekaran82 on 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,

gchandrasekaran82
Regular Participant
Regular Participant

Posts : 33
Join date : 2011-02-16

Back to top Go down

Re: How to use If statement?

Post by Yure_ts on 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

Yure_ts

Posts : 2
Join date : 2011-02-22

Back to top Go down

Re: How to use If statement?

Post by Priyanka on Fri Mar 04, 2011 12:23 pm

Thanks for sharing

Priyanka
Regular Participant
Regular Participant

Posts : 27
Join date : 2010-10-04

Back to top Go down

Re: How to use If statement?

Post by rohit13 on 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...

_________________
Radical QA
http://radical-qa.blogspot.in/

rohit13
Master
Master

Posts : 180
Join date : 2012-03-29
Age : 30
Location : INDIA

http://radical-qa.blogspot.in/

Back to top Go down

Re: How to use If statement?

Post by rashmichauhan on 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

rashmichauhan

Posts : 3
Join date : 2012-10-03

Back to top Go down

Re: How to use If statement?

Post by Qasubzero on 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.

Qasubzero

Posts : 1
Join date : 2013-10-07

Back to top Go down

Re: How to use If statement?

Post by ccox on 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.

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: How to use If statement?

Post by kashyap_guru on 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??

kashyap_guru
Active particpant
Active particpant

Posts : 24
Join date : 2013-10-16
Age : 29
Location : India

Back to top Go down

Re: How to use If statement?

Post by Sponsored content Today at 3:20 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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