Python conditional statements
Hi! Has anyone been facing an issue with conditional statements using python?
I am to execute a code which checks for a file in a particular folder and deletes it if found. Also, I have been having issues using inputs from the keyboard. The code terminates whenever an input from the keyboard is required.
PS: any examples with if-else statements (python only) would be appreciated.
I am currently on version 188.8.131.52.
Following is the code with the keyboard input:
hwndSource = Aliases.I_Software.HwndSource_LogonWindow
comboBox = hwndSource.LogonWindow.ProfilesComboBox
As far as conditional statements go, I haven't been able to figure out a way to script it.
(I am assuming testcomplete has a different syntax/ built in functions that I'm not used to)
I would like to see the "Python conditional statements" that is not working for you, as you started your first sentence with this question.
In the coding you have provided, you are clicking on the dropdown of comboBox, then entering 'a' followed by 'return' on the hwndSource, then entering 'return' on the comboBox. This doesn't deem to be consistent.
Here's the code for the conditional statements:
I_Software = Aliases.I_Software
button = I_Software.HwndSource_HomeScreenWindow.HomeScreenWindow_.RemoveImagesButton
if aqObject.CheckProperty(button.Image, "Enabled", cmpEqual, True):
imageSelector = I_Software.HwndSource_ImageSelector.ImageSelector
homeScreen = I_Software.HwndSource_HomeScreenWindow.HomeScreenWindow_
listView = homeScreen.GalleryList
listView.HScroll.Pos = 0
If the property value of "Enabled" is True for button.Image, then the statement is true. Which means it will perform the following,
imageSelector = I_Software.HwndSource_ImageSelector.ImageSelector button.ClickButton() imageSelector.SelectAllButton.ClickButton() imageSelector.OKButton.ClickButton()
What's the exact issue with the conditional statement?
The problem here is that it performs the statements mentioned above if the button is enabled, but terminates the code if it is not.
If you get the following appearing,
Then change the project settings, on error to continue running,
The results will look like this afterwards,
This reason it fails - "If the verification succeeds, the method posts a success message to the test log; otherwise it posts a failure message."
This is what I see now. the digital import object is present in the object browser and the image was imported before I changed the settings to 'continue running'.
Suddenly, it does not recognize the object.
Because the checkpoint has failed, it's not performing the condition in the if statement.
If you debug, and step through your coding. You will see exactly what it's doing.