Create if else sceneario to meet the precondiotions of test

Best practices, code snippets for common functionality, examples, and guidelines.
MartinKubal
Posts: 10
Joined: Wed Aug 16, 2017 8:16 pm

Create if else sceneario to meet the precondiotions of test

Post by MartinKubal » Fri Sep 08, 2017 9:12 am

Hi,
I am really newbie, working with ranorex 1 month.
I need to make Setup area for few test cases for our mobile app in order to meet the preconditions. It is quite simple, we have in app checkbox Remember me (for login credentials), but its not a real checkbox, it is image which change, when you tap on it. The ID will be same.

Xpath for this element is ...img[#'cb'] and only parametr, tha is changing is SRC (could be .......unchecked.png and ........checked.png). And I need to create condition when I open the app, check wether is "checked" or not and then perform the test or touch on the element to change it to "unchecked" and vice versa.

I know I have to do it in user code, but I have almost any experience with programming, so I would appreciate your help please. I've tried write code in C# accordingly to some tutorials but it wasn't working.

1 sceneario:
Open app
Check /img[#'cb']
IF unchecked continue with tests
ELSE touch the element /img[#'cb'] to make it unchecked
Validate if it is really unchecked and then continue with test

2 sceneario:
Open app
Check /img[#'cb']
IF checked continue with tests
ELSE touch the element /img[#'cb'] to make it checked
Validate if it is really checked and then continue with test

Thank you for your help.

MartinKubal
Posts: 10
Joined: Wed Aug 16, 2017 8:16 pm

Re: Create if else sceneario to meet the precondiotions of test

Post by MartinKubal » Mon Sep 18, 2017 9:02 am

Never mind, I did found solution allready.
Attachments
if-else.txt
(342 Bytes) Downloaded 62 times