Unexpected behavior executing if, elif, else statement in Python
I wrote an if, elif, and else routine to checkpoint a header name and write the appropriate password into a required password field. When I ran the script routine it resulted in unexpected behavior. The first expression (checkpoint function) resulted in true but instead of executing the associated code block (touch & keys) and dropping out it ran the next elif, which as expected failed and then it ran the statements from the previous if statement. It completed the task but ultimately failed the test.
I’ve run similar if statements before without issue. Please see attached code snippet and log.
Any thoughts as to why this would be happening would be appreciated.
headerDeviceName can only contain "SR-506-0801" OR "SR506-0701" text, is that correct?
Since you are calling check property for both text, on lines 1 and 2. If the verification succeeds, the method posts a success message to the test log; otherwise it posts a failure message. Hence, check property is failing on "SR506-0701", line 28.