I wondered if you could help with an issue I am getting with one of my assertions:
Currently, I have a test that logs a user type onto the system and then checks to see if the buttons displayed are all there. I do this by using my own command isElementPresent which then links to the selenium driver.find_element .
result = self.isElementPresent(self._timesheets_nav, locatorType=“link”)
result = self.isElementPresent(self._awaiting_pay_bill_nav, locatorType=“link”) and result
result = self.isElementPresent(self._payments_nav, locatorType=“link”) and result
If the elements are on the page then true is passed back to the test and this is then asserted against with assert result == True. So far so good…
The issue I am having is that for the reverse of this check - i.e. checking that buttons are NOT displayed. For this I am using the same check of isElementPresent but adding a “not” in front of the check so it still gives me a True response if the element is not displayed. This way I can still assert that against the same result.i.e. == True
result = not self.isElementPresent(self._my_payments_button, locatorType=“link”)
result = (not self.isElementPresent(self._my_holiday_button, locatorType=“link”)) and result
result = (not self.isElementPresent(self._my_compliances_button, locatorType=“link”)) and result
result = (not self.isElementPresent(self._my_invoices_button, locatorType=“link”)) and result
If I run this test locally then my tests all pass but if I check the Test Project Reports then these items are failing. I assume that this is because it is failing to find the elements and so reporting a failure even though the Assert is passing.