IF Then else statement - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: IF Then else statement (/Thread-IF-Then-else-statement--2787) Pages:
1
2
|
IF Then else statement - swetha.b - 12-03-2009 Hi ALL, I am novice in QTP. So could anybody explain me this small statemnt. I am testing a .Net application where a scenario falls like this : If 'Preferred comm' = Email. Enter email in the 'Email' field else if 'preferred comm' = fax. Enter fax in the 'Fax' field. So, how do I write these statements in expert view? as I cannot select a object from object repository in expert view likewise in Keyword View. ??? RE: IF Then else statement - Jyobtech - 12-03-2009 HI , You can use the If...Then...ElseIf statement if you want to select one of many blocks of code to execute.Then the statement as follows, If 'Preferred comm' = Email.Enter email in the 'Email' field Then Code: document.write("..") The above If...Then...ElseIf statement , you can write after 'Preferred comm' in expert view. RE: IF Then else statement - swetha.b - 12-03-2009 Hey thanks jyo One more doubt to go In contest to above post. While running a test how do I select(Manually) preferred communication as Email/Phone/Fax so that respective field is filled with the value I specified in the script? Do I have to use a checkpoint before preferred comm statement? RE: IF Then else statement - swetha.b - 12-04-2009 Hey can anybody help me urgent !!!! Here are my if and else statements listed: Code: If Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebList("ctl00$ContentPlaceHolder1$ddlP").Select ("Email") = True Then Logic is this: If preferred coom is Email : Fill Email field else if preferred comm is Phone : Fill Phone Filed else fill fax field. My problem: Weblist - Preferred comm is always defaulted to "Email". So first time when I run the script First If statment should be true and execute immediate next statement. But inreturn execution goes to the Elseif statement and since elseif is also false last statmemt is excecuted. Implies Fax field is filled. Also noticed that after the elseif statement execution Preferred comm was set to Phone???? RE: IF Then else statement - swetha.b - 12-04-2009 Can anybody please provide me some help on this regard??? RE: IF Then else statement - nil - 12-04-2009 Hi Swethaaaaaaa, Code: If Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebList("ctl00$ContentPlaceHolder1$ddlP").Select ("Email") = True Then This will work selected item should be verified as below Code: Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebList("ctl00$ContentPlaceHolder1$ddlP").GetROProperty("Selection")="Email"[hr] RE: IF Then else statement - Jyobtech - 12-04-2009 Hi Swetha, You can go this script , It may work .Here I used Exist Instead of (=True) Code: If Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebList("ctl00$ContentPlaceHolder1$ddlP").Select ("Email").Exist Then RE: IF Then else statement - nil - 12-04-2009 Hi Jyo statement Code: Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebList("ctl00$ContentPlaceHolder1$ddlP").Select ("Email").Exist will not work Exist is used to check object and not value in weblist ~Nilesh :-) RE: IF Then else statement - MahalakshmiDevi - 12-04-2009 Code: var= Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebList("ctl00$ContentPlaceHolder1$ddlP").GetROProoerty("Selection") u can also switch statement tocover the above scenario : Code: var= Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebList("ctl00$ContentPlaceHolder1$ddlP").GetROProoerty("Selection") RE: IF Then else statement - nil - 12-04-2009 hi through this statement Code: Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebList("ctl00$ContentPlaceHolder1$ddlP").GetROProperty("Selection") you can get the selected Item. further you can implement it through any logic Thanks ~Nilesh |