Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is a demo TestComplete test written in VBScript to test BMI Calculator native iOS app with Appium
Sub BmiCalculatorTest()
On Error Resume Next
'Create an instance of DesirecCapabilities, CapabilityType and By Class using CLR Bridge &
'dotNet Property
Set objCapabilities = dotNet.OpenQA_Selenium_Remote.DesiredCapabilities.zctor()
Set objCapabilityType = dotNet.OpenQA_Selenium_Remote.CapabilityType
'By class provides ability to describe locator types supported by WebDriver
Set objBy = dotNet.OpenQA_Selenium.By
'Set up the capabilities to run test on iOS application on Sauce Labs
objCapabilities.SetCapability objCapabilityType.BrowserName, "iOS"
objCapabilities.SetCapability objCapabilityType.Version, "6.1"
objCapabilities.SetCapability objCapabilityType.Platform, "Mac"
'Set up the RemoteWebDriver
Set objUri = dotNET.System.Uri.zctor("http://mymacmachine:4723/wd/hub")
Set objDriver = dotNET.OpenQA_Selenium_Remote.RemoteWebDriver.zctor_3(objUri,Capabilities)
'Get the Hight text field and enter value
Set objHeightField = objDriver.FindElement(objBy.Name("Height"))
objHeightField.SendKeys "181"
'Get the Weight text field and enter value
Set objWeightField = objDriver.FindElement(objBy.Name("Weight"))
objWeightField.SendKeys "80"
'Get the Calculate button and tap/click on it
Set objCalculateButton = objDriver.FindElement(objBy.Name("Calculate"))
objCalculateButton.Click
'Get the Bmi lables
Set objBmiLabel = objDriver.FindElement(objBy.Name("bmi"))
Set objBmiCategoryLabel = objDriver.FindElement(objBy.Name("category"))
'Check labels for expected value
If aqObject.CompareProperty(objBmiLabel.Text, cmpEqual, "24.42") Then
Log.Checkpoint "Calculated BMI is correct!"
Else
Log.Error "Calculated BMI does not match expected value"
End If
If aqObject.CompareProperty(objBmiCategoryLabel.Text, cmpEqual, "Normal") Then
Log.Checkpoint "BMI Category is correct!"
Else
Log.Error "BMI Category does not match with expected value"
End If
objDriver.Quit
If Err.Number <> 0 Then
Log.Error "Unexpected error [" & Err.Number & "] " & Err.Description & " occured while test execution"
End If
On Error GoTo 0
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.