# -*- coding: utf-8 -*- # A quick introduction to implementing scripts for BDD tests: # # This file contains snippets of script code to be executed as the .feature # file is processed. See the section 'Behaviour Driven Testing' in the 'API # Reference Manual' chapter of the Squish manual for a comprehensive reference. # # The decorators Given/When/Then/Step can be used to associate a script snippet # with a pattern which is matched against the steps being executed. Optional # table/multi-line string arguments of the step are passed via a mandatory # 'context' parameter: # # @When("I enter the text") # def whenTextEntered(context): # # # The pattern is a plain string without the leading keyword, but a couple of # placeholders including |any|, |word| and |integer| are supported which can be # used to extract arbitrary, alphanumeric and integer values resp. from the # pattern; the extracted values are passed as additional arguments: # # @Then("I get |integer| different names") # def namesReceived(context, numNames): # # # Instead of using a string with placeholders, a regular expression can be # specified. In that case, make sure to set the (optional) 'regexp' argument # to True. import names @Given("Application started") def step(context): startApplication("denali") @Given("The Home Screen is visible") def step(context): test.compare(waitForObjectExists(names.o_homeScreen_backgroundRect_Rectangle).visible, True) @Given("The Home Screen has Start Treatment button") def step(context): test.compare(waitForObjectExists(names.o_startTreatmentScreen_Back_Button).visible, True) test.compare(str(waitForObjectExists(names.o_homeScreen_Start_Treatment_Text).text), "Start Treatment") @When("Click on the Treatment button") def step(context): mouseClick(waitForObject(names.o_homeScreen_Start_Treatment_Text)) @Then("Expected to see the treatment screen") def step(context): test.compare(waitForObjectExists(names.o_startTreatmentScreen_ui).visible, True) @Then("There is a back button with text back") def step(context): test.compare(waitForObjectExists(names.o_startTreatmentScreen_Back_Button).visible, True) test.compare(str(waitForObjectExists(names.o_startTreatmentScreen_Back_Button).text), "Back") @When("Click on the Treatment back button") def step(context): mouseClick(waitForObject(names.o_startTreatmentScreen_Back_Button)) @Then("Should go back to the home screen") def step(context): test.compare(waitForObjectExists(names.o_homeScreen_backgroundRect_Rectangle).visible, True) @When("Click on the Manager button") def step(context): mouseClick(waitForObject(names.o_homeScreen_Treatment_Manager_Text)) @Then("Expected to see the Manager screen") def step(context): test.compare(waitForObjectExists(names.o_treatmentMansagerScreen_ui).visible, True) @Then("Should stay on the Manager Screen") def step(context): test.compare(waitForObjectExists(names.o_treatmentMansagerScreen_ui).visible, True) @When("Click on the Manager back button") def step(context): mouseClick(waitForObject(names.o_treatmentMansagerScreen_Back_Button))