Using Pass Execution If to run certain test cases

2,131 views
Skip to first unread message

N.T.

unread,
Nov 24, 2015, 3:56:55 AM11/24/15
to robotframework-users
To give an explanation I run automated scripts for different sites with different languages but ideally have the same behavior.

So instead of making different test cases for different sites I use the same test case and import a different variable file that has different values depending on the country.

However there are some instances where one country site is different from the other. An example is that only our Japan has a requirement when you create a user you not only need to give your first name and last name but you need to give your phonetic first name and last name.

Instead of making a separate testsuite for that I was wondering if I could reuse the ones I used for the non-Japanese site and then make extra test cases that only run for Japan.

So it looks like this:

Successful Registration
   
Search    ${productname}
   
Select in Stock Product
   
Select any available size
   
Add to Cart
   
Go to Cart Page
   
Proceed to Checkout
   
Register from Checkout
   
Enter First Name    ${registration_firstname}
   
Enter Last Name    ${registration_lastname}
    $
{dummyEmail}=    Generate Dummy Email
   
Enter Email Address    ${dummyEmail}
   
Enter Password    ${registration_password}
   
Enter Confirmed Password    ${registration_password}
   
Register
   
Welcome Message should appear
   
[Teardown]    Log out


Blank Phonetic First Name
   
[Documentation]    Test should only run if it is an AJP site
   
[Tags]    test
   
[Setup]    Pass Execution if    '${COUNTRY}' !== 'JP'    This is not an JP test
   
Search    0010248198.7393
   
Select in Stock Product
   
Select any available size
   
Add to Cart
   
Go to Cart Page
   
Proceed to checkout
   
Register from Checkout
   
Enter Phonetic Last Name    ${EMPTY}
   
Enter Phonetic First Name    ${registration_phonetic_firstname}
   
Register
   
Registration Error Message should appear    id=register.phoneticLastName

So currently the country is set to "AU" so ideally it should fail. But this is what I get in the logs:

Evaluating expression ''AOP' !== 'AJP'' failed: SyntaxError: invalid syntax (<string>, line 1)


Am I doing something wrong? should I be using a different keyword? I just want to prevent myself for rewriting stuff that does the same thing.

 

Hélio Guilherme

unread,
Nov 24, 2015, 4:53:39 AM11/24/15
to robotframework-users
So currently the country is set to "AU" so ideally it should fail. But this is what I get in the logs:

Evaluating expression ''AOP' !== 'AJP'' failed: SyntaxError: invalid syntax (<string>, line 1)


You are using JavaScript syntax ;) 

You should use != like in:
Pass Execution if    '${COUNTRY}' != 'JP'    This is not an JP test

Having that step in the [Setup] won't avoid running the test. Better try to have as the first test step.


Wladislaw Wagner

unread,
Nov 24, 2015, 6:18:51 AM11/24/15
to heliox...@gmail.com, robotframework-users
This is a case where a SKIP option oder keyword (which we do not have in Robot Framework, yet ) would come in handy ;-)))

May be alternatively one could tag this test cases with e.g. 'JP' or 'AJP' and use '--exclude' cli option when running the non-JP test cases?

Cheers
Tset

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

N.T.

unread,
Nov 24, 2015, 9:26:41 PM11/24/15
to robotframework-users
Oh my God it worked!

And so stupid I didn't even realize the typo until now. I fixed that and moved it as a first step instead of putting it as a test setup as you said.

Thank you so much for your help! 
Reply all
Reply to author
Forward
0 new messages